I posted this topic earlier, however can not see the same into list thats why reposting it.
I have a image "test.gif" (GIF image) and accidentally I change the extension to .jpeg "test.jpeg" but Image's MIME type is still JPEG Image so if i scale it using IM (resizing/ thumbnail) how this image will be treated as JPEG image because the extension is .jpeg/jpg or as GIF image because MIME type of the image is "Image/JPEG"?
Thanks for all the help and support.
Scaling Image if MIME type is different than image extension
Re: Scaling Image if MIME type is different than image extension
I think the earlier post I was talking about is not actually posted, so please reply to this post.
Thanks for all the help and support.
Thanks for all the help and support.
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: Scaling Image if MIME type is different than image extension
Most of the time IM will try to work out what 'type' an image file is basied on the 'magic' of the file. That is the contents of the file determines the file type IM attempts to use
However if magic determination fails, the suffix is used.
The prefix format: however will override the normal magic determination.
I am not exactly certain of the exact order in which Im attempts to read a unknown image file. But it will do its best to figure it out.
However if magic determination fails, the suffix is used.
The prefix format: however will override the normal magic determination.
I am not exactly certain of the exact order in which Im attempts to read a unknown image file. But it will do its best to figure it out.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/
Re: Scaling Image if MIME type is different than image extension
I didn't understand what do you mean by "unknown image type".
If IM determines the image type or magick is JPEG for an image whose extension in the name is .gif, so it will treat it at JPEG write? and if I am doing this
convert test.gif -resize 200x200> -write test_1.gif
where test is JPEG type of image, will IM do a conversion internally to convert JPEG into GIF and scaled image will be of type GIF? or IM will save it as JPEG but with .gif extension?
Thanks for all the help and support.
If IM determines the image type or magick is JPEG for an image whose extension in the name is .gif, so it will treat it at JPEG write? and if I am doing this
convert test.gif -resize 200x200> -write test_1.gif
where test is JPEG type of image, will IM do a conversion internally to convert JPEG into GIF and scaled image will be of type GIF? or IM will save it as JPEG but with .gif extension?
Thanks for all the help and support.
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: Scaling Image if MIME type is different than image extension
When reading it will either
However after the image is read in the save to a file with a suffix of 'GIF' will save as a GIF image regardless of the source!
If you want it as a JPEG image with a .gif suffix you can override this with a prefix to force the output format.
For example
will write a file "test_1.gif" containing a image in JPEG format!!!!
NOTE the escape for the '>' otherwise the shell may create a file for the commands standard output and Im will think "200x200" is the output filename!!!!
Also -write is only needed if the save is in the middle of a long sequence of operations. The last argument of convert is assumed to be a '-write' operation.
In your previous command the shell would create a -write file
and remove it from IM arguments!
- attemtp to read it a GIF and fail (bad magic) then determine it is JPEG and correctly read it.
- OR just note that it is JPEG and read it as JPEG without even trying to read as GIF.
However after the image is read in the save to a file with a suffix of 'GIF' will save as a GIF image regardless of the source!
If you want it as a JPEG image with a .gif suffix you can override this with a prefix to force the output format.
For example
Code: Select all
convert test.gif -resize 200x200\> JPEG:test_1.gif
NOTE the escape for the '>' otherwise the shell may create a file for the commands standard output and Im will think "200x200" is the output filename!!!!
Also -write is only needed if the save is in the middle of a long sequence of operations. The last argument of convert is assumed to be a '-write' operation.
In your previous command the shell would create a -write file
and remove it from IM arguments!
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/
Re: Scaling Image if MIME type is different than image extension
i tried this command and I wanted the image to be scaled if its size is greater than 200x200 however when image type is JPEG and I store it as GIF IM actually scaled it to be 200x200, why is is so?
Is there a way I could find out type of the image (a command) as I am going to use convert for generic image types (from java) and will provide the new image name based on original image name.
Thanks for all the help & support.
Is there a way I could find out type of the image (a command) as I am going to use convert for generic image types (from java) and will provide the new image name based on original image name.
Thanks for all the help & support.
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: Scaling Image if MIME type is different than image extension
Because the shell was seeing the '>' and not IM. As I mentioned before.
the shell sees '> -write' so it removes this and creates a file called "-write". This is completely seperate to IM itself.
1/ you don't need a -write option the last argument is the file to create
2/ your must backslash or quote the > so the shell does not act on it but passes it to IM.
the shell sees '> -write' so it removes this and creates a file called "-write". This is completely seperate to IM itself.
1/ you don't need a -write option the last argument is the file to create
2/ your must backslash or quote the > so the shell does not act on it but passes it to IM.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/