resolution problem

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
srikrishnan
Posts: 10
Joined: 2009-06-30T23:14:10-07:00
Authentication code: 8675309

resolution problem

Post by srikrishnan »

Hi All,

I have a requirement to convert set of tif images to jpeg format. For this purpose I have written a perl script. Through which I called image magick successfully. At the conversion stage 300x300 dpi resolution need to be changed to 150x150 resolution.

I have used -resample command for this purpose. Imagemagick shows the converted file correctly. But Windows image viewers and photoshop shows only the original resolution of the tif image.

I have read about the problem in imagemagick Documentation, it clearly explains that:

"Note that Photoshop stores and obtains image resolution from a proprietary embedded profile. If this profile exists in the image, then Photoshop will continue to treat the image using its former resolution, ignoring the image resolution specified in the standard file header."

How can I remove the proprietary embedded profile and make all the windows image viewers and photoshop to show the correct dpi?

Thanks in advance,
Srikrishnan
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: resolution problem

Post by fmw42 »

I am not sure about this, but try using -strip after reading in the image.

see http://www.imagemagick.org/script/comma ... k4e2#strip
srikrishnan
Posts: 10
Joined: 2009-06-30T23:14:10-07:00
Authentication code: 8675309

Re: resolution problem

Post by srikrishnan »

Thanks for your suggestion,

I have tried the option "-strip" it reduces the 125KB file to 65KB, but even original resolution not shown by the "Windows Pictures and Fax Viewer" or any other windows softwares.

my syntax is as follows:

convert c:/sample.jpg -strip c:/sample.jpg

thanks,
Srikrishnan
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: resolution problem

Post by fmw42 »

IM is changing the quality factor when you go from jpg to jpg. if it cannot determine the quality factor it uses a default of 92. Furthermore, it is not a good idea to go from jpg to jpeg as IM will decompress and recompress the image which will cause extra loss of quality as jpeg is not a loss-less compression. You can force the compression to higher or lower values using -quality. If you want a smaller file size, then use a smaller compression.

see
http://www.imagemagick.org/script/comma ... p4#quality
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: resolution problem

Post by anthony »

More than likely it is a separate 'resolution' setting from the images normal default. Photoshop especially likes to use its own resolution setting over and able the images normal resolution, that IM sets.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
srikrishnan
Posts: 10
Joined: 2009-06-30T23:14:10-07:00
Authentication code: 8675309

Re: resolution problem

Post by srikrishnan »

Thanks for everyone,

now I have used the option "-strip" as follows:

convert -strip -density 150 -quality 80 "c:/sample.tif" +antialias -colorspace RGB "c:/sample.jpg"

it removes the embedded profile of photoshop and all the viewers shows exactly as per our requirement.

Thanks,
Srirkishnan
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: resolution problem

Post by anthony »

The +antialias is not needed. You don't make use of the setting.

Also the -strip should be placed after the image read (when you have an image in memory to strip.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
srikrishnan
Posts: 10
Joined: 2009-06-30T23:14:10-07:00
Authentication code: 8675309

Re: resolution problem

Post by srikrishnan »

Hi Anthony,

thanks for your mail.

But in my case, as per i mentioned in my previous mail, if I use "-strip" after the image read, it will not stripped out the profile.

Thanks,
Srikrishnan
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: resolution problem

Post by anthony »

That seems strange to me!
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: resolution problem

Post by fmw42 »

Was -strip change not too long ago to leave the profiles. I seem to recall something about that, though not completely sure. So perhaps one needs -strip +profile after reading the image.
jonrescca
Posts: 8
Joined: 2011-11-09T00:25:50-07:00
Authentication code: 8675308

Re: resolution problem

Post by jonrescca »

For photoshop to respect the density set by imagemagick, we use the
+profile "8bim"
option

Code: Select all

convert -units PixelsPerInch input.tif +profile "8bim" -density 150 output.jpg
Post Reply