Changing DPI result different quality (PS-IM)

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
jeffreyg
Posts: 14
Joined: 2014-02-10T03:42:50-07:00
Authentication code: 6789

Changing DPI result different quality (PS-IM)

Post by jeffreyg »

I'm trying to change the DPI of an image to 100. Its a 300 DPI image. When I use Adobe Photoshop I get a different result when I change the DPI (Resolution to 100) then when I'm using ImageMagick with PHP.

I'm using ImageMagick-6.8.8-1-Q16-x86 and I used the -dll.-exe installer to get it installed properly. I use it on Windows 7 Ultimate 32-bit.

I use the following code to change the DPI of my image:

Code: Select all

exec("convert -strip -units PixelsPerInch  input.jpg -resample 100 -set density 100 output.jpg", $return);
I get the follow result (having photoshop to the left with 100 DPI (Resolution to 100) and ImageMagick with resample + density 100 to the right):

Image

Full image url: http://postimg.org/image/t265d59s9 (Press full size to see the difference better).

The original image I'm using can be found here:

http://onlyhdwallpapers.com/wallpaper/e ... 453029.jpg

The Photoshop result can be found here:

http://postimg.org/image/i1jf6xszb/

And the ImageMagick result can be found here:

http://postimg.org/image/yw1ahdw4d/

All the details are the same, when I both open them in photoshop. But there is a difference in quality between changing the DPI in Photoshop and ImageMagick. Is there any explanation why there is a difference between these 2? And how can I fix it to get ImageMagick giving me the exact same output as Photoshop?
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Changing DPI result different quality (PS-IM)

Post by snibgo »

"-resample" changes metadata but also changes the size of the image. When Photoshop resizes, I've heard that it also sharpens. If you want IM to sharpen, you have to ask for it eg with "-sharpen" or "-unsharp". See http://www.imagemagick.org/script/comma ... hp#sharpen etc.
snibgo's IM pages: im.snibgo.com
jeffreyg
Posts: 14
Joined: 2014-02-10T03:42:50-07:00
Authentication code: 6789

Re: Changing DPI result different quality (PS-IM)

Post by jeffreyg »

Thank you very much! I've added it to my code and with a little bit of trying, the output looks more the same. Now I only have to try to find the right values but I'll manage that.
Post Reply