Hello,
I am using ImageMagick (6.3.0, Windows Version) to identify the dpi value of an image and then further process it depending on the result.
Now I discovered a problem with one JPEG image. ImageMagick says it has a resolution of 300dpi. But Adobe Photoshop and Gimp tell me it only has 72dpi. I also checked it with PaintShop Pro with 300dpi as the result. I am a bit confused. Is ImageMagick/PaintShopPro right and Photoshop/Gimp wrong ? Or has ImageMagick a problem with the dpi value ? Is their a way to get the correct dpi value with ImageMagick ?
Here you can download the image for testing.
Problem with false(?) dpi value
-
- Posts: 1015
- Joined: 2005-03-21T21:16:57-07:00
It's a bit strange for me that an image has two different dpi values and I am not sure which one is the real dpi value. Or has the image just two ? It is valid to create a JPEG image with different dpi values in the JPEG and EXIF header ?
Can I get the dpi value from the EXIF header with ImageMagick ?
The problem is, the person who send me the picture says I should handle it as a 72dpi image, but ImageMagick thinks it's 300dpi. How can the get ImageMagick to recognize the image as 72dpi ?
Can I get the dpi value from the EXIF header with ImageMagick ?
The problem is, the person who send me the picture says I should handle it as a 72dpi image, but ImageMagick thinks it's 300dpi. How can the get ImageMagick to recognize the image as 72dpi ?
-
- Posts: 1015
- Joined: 2005-03-21T21:16:57-07:00
If you want to force the JPG header to 72 dpi use:
Pete
Code: Select all
convert input.jpg -units pixelsperinch -density 72x72 output.jpg
-
- Posts: 1015
- Joined: 2005-03-21T21:16:57-07:00
BTW. That command will also involve recompressing the image which by default will use a quality of 75. You can use "-quality 95" to get a better quality image but you can't avoid the image degradation caused by decompressing and recompressing it so you should try to combine these operations together with anything else that you do to the image.
Pete
Pete
Thanks Pete!
But my problem is a bit different. I am already converting automatically all incoming pictures using "convert" in my software. First I have to check with "identify" how many dpi the picture has. Depending on the result and some other informations I have to convert the pictures in different ways. My problem is that the above picture is treated in the fully automated process as a 300dpi picture, because "identify" only gives me the information that it is 300dpi. But the person who sends the picture into my system wants it to be treated as a 72dpi picture, because their Photoshop software says it is 72dpi. Maybe the problem can occur with different pictures, too. So I would like to know if I can trust the results from "identify" and how I can handle special cases like the above picture ??
But my problem is a bit different. I am already converting automatically all incoming pictures using "convert" in my software. First I have to check with "identify" how many dpi the picture has. Depending on the result and some other informations I have to convert the pictures in different ways. My problem is that the above picture is treated in the fully automated process as a 300dpi picture, because "identify" only gives me the information that it is 300dpi. But the person who sends the picture into my system wants it to be treated as a 72dpi picture, because their Photoshop software says it is 72dpi. Maybe the problem can occur with different pictures, too. So I would like to know if I can trust the results from "identify" and how I can handle special cases like the above picture ??
-
- Posts: 1015
- Joined: 2005-03-21T21:16:57-07:00
The problem is that Photoshop is getting the dpi from a Makernote in the header. Makernotes are proprietary info put there by, for example, Nikon or Canon when the image was originally produced by a scanner or camera.
AFAIK ImageMagick can't read the Makernote. I've done a quick google and can't find any software that reads a Makernote (not too surprising).
It looks like you'll have to handle those files as a special case somehow unless someone on this forum has a way around this.
Sorry
Pete
P.S. If you process the file as 72x72 does it come out the other end the way they would have intended? Insisting on 72dpi seems a bit strange since that resolution implies the image is only being looked at on a monitor in which case the dpi is irrelevant anyway.
AFAIK ImageMagick can't read the Makernote. I've done a quick google and can't find any software that reads a Makernote (not too surprising).
It looks like you'll have to handle those files as a special case somehow unless someone on this forum has a way around this.
Sorry
Pete
P.S. If you process the file as 72x72 does it come out the other end the way they would have intended? Insisting on 72dpi seems a bit strange since that resolution implies the image is only being looked at on a monitor in which case the dpi is irrelevant anyway.