Forcing a change in resolution with convert

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
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Post by anthony »

Photoshop saved resolution in a non-standard way in TIF files. That is the problem.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
el_supremo
Posts: 1015
Joined: 2005-03-21T21:16:57-07:00

Post by el_supremo »

FWIW: I used the command line "convert" to convert a JPG, which "identify" says has a resolution of 300x300 dpi, to a PCT which identify says is 72x72 with undefined units.

I've had a look at the pict.c coder and I think there are two problems.
ReadPICTImage uses the ReadPixmap macro to read the x and y resolution from the file header but it doesn't seem to do anything with this information which would result in default resolution and units no matter what resolution was written in the file header.
There may also be a bug in WritePICTImage. When it writes out the x and y resolution it does it like this:

Code: Select all

  (void) WriteBlobMSBShort(image,(unsigned short) x_resolution);
  (void) WriteBlobMSBShort(image,0x0000);
  (void) WriteBlobMSBShort(image,(unsigned short) y_resolution);
  (void) WriteBlobMSBShort(image,0x0000);
whereas the ReadPixmap macro reads them in like this:

Code: Select all

  pixmap.horizontal_resolution=ReadBlobMSBLong(image); \
  pixmap.vertical_resolution=ReadBlobMSBLong(image); \
I suspect that WritePICTImage should either write the 0x0000 before the resolutions (because it is MSB first) or do this:

Code: Select all

  (void) WriteBlobMSBLong(image,(unsigned long) x_resolution);
  (void) WriteBlobMSBLong(image,(unsigned long) y_resolution);

Pete
el_supremo
Posts: 1015
Joined: 2005-03-21T21:16:57-07:00

Post by el_supremo »

thank you for checking this out el_supremo
You're welcome.
I´ll have to wait till someone else fixes it... (If it will ever be done)
The IM guys are very good at fixing up reported bugs and issuing a new release of the code, so if you can recompile from source you may have a fix in a few days.
the GIMP can't open PCT pics
The problem I noted, with the way that WritePICTImage seems to write out the resolutions, may explain why PSP X cannot open the .pct file produced by "convert". It just says "An error has occurred while trying to read from the file" and gives up. It may be seeing the original 300dpi resolution as 300*65536 dpi and barfing.

Pete
el_supremo
Posts: 1015
Joined: 2005-03-21T21:16:57-07:00

Post by el_supremo »

I figured out and posted a patch to the Bugs list. No reply, but it appears that the patch was accepted and is now in the sources for 6.3.0-7.

Pete
el_supremo
Posts: 1015
Joined: 2005-03-21T21:16:57-07:00

Post by el_supremo »

I'm afraid I can't help you with that Haffi. I'm using Windows :oops:

Pete
Post Reply