Forcing a change in resolution with convert
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
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/
https://imagemagick.org/Usage/
-
- Posts: 1015
- Joined: 2005-03-21T21:16:57-07:00
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:
whereas the ReadPixmap macro reads them in like this:
I suspect that WritePICTImage should either write the 0x0000 before the resolutions (because it is MSB first) or do this:
Pete
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);
Code: Select all
pixmap.horizontal_resolution=ReadBlobMSBLong(image); \
pixmap.vertical_resolution=ReadBlobMSBLong(image); \
Code: Select all
(void) WriteBlobMSBLong(image,(unsigned long) x_resolution);
(void) WriteBlobMSBLong(image,(unsigned long) y_resolution);
Pete
-
- Posts: 1015
- Joined: 2005-03-21T21:16:57-07:00
You're welcome.thank you for checking this out el_supremo
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.I´ll have to wait till someone else fixes it... (If it will ever be done)
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.the GIMP can't open PCT pics
Pete
-
- Posts: 1015
- Joined: 2005-03-21T21:16:57-07:00
-
- Posts: 1015
- Joined: 2005-03-21T21:16:57-07:00