Hi there, as there were no reaction on my problem on magick-bugs I fixed it myself.
The PSD writer now supports saving PixelsPer(Inch|Centimeter) values. If there are no objections please apply the patch to ImageMagick (it is against version 6.5.0-9). thanks, Markus --- ImageMagick-6.5.0-9/coders/psd.c 2009-03-24 03:39:05.000000000 +0100 +++ ImageMagick-6.5.0-9_patched/coders/psd.c 2009-03-27 13:00:00.107158090 +0100 @@ -1652,6 +1652,33 @@ (void) WriteBlobByte(inImage,0); } +static void WriteResolutionInfo(Image *image) +{ + unsigned long xres_fix, yres_fix; + unsigned short psd_unit; + + if(image->units == PixelsPerCentimeterResolution) { + xres_fix = 2.54 * image->x_resolution * 65536.0 + .5; + yres_fix = 2.54 * image->y_resolution * 65536.0 + .5; + psd_unit = 2; + } else { + xres_fix = image->x_resolution * 65536.0 + .5; + yres_fix = image->y_resolution * 65536.0 + .5; + psd_unit = 1; + } + + (void) WriteBlob(image, 4, (unsigned char *) "8BIM"); + (void) WriteBlobMSBShort(image, 0x03ED); + (void) WriteBlobMSBShort(image, 0); + (void) WriteBlobMSBLong(image, 16); /* resource size */ + (void) WriteBlobMSBLong(image, xres_fix); + (void) WriteBlobMSBShort(image, psd_unit); /* hres unit */ + (void) WriteBlobMSBShort(image, psd_unit); /* width unit */ + (void) WriteBlobMSBLong(image, yres_fix); + (void) WriteBlobMSBShort(image, psd_unit); /* vres unit */ + (void) WriteBlobMSBShort(image, psd_unit); /* height unit */ +} + static MagickBooleanType WritePSDImage(const ImageInfo *image_info,Image *image) { const char @@ -1680,12 +1707,13 @@ channelLength, layer_count, layer_info_size, - rounded_layer_info_size; + rounded_layer_info_size, + res_extra; Image * tmp_image = (Image *) NULL, * base_image = force_white_background ? image : GetNextImageInList(image); - + /* Open output image file. */ @@ -1763,17 +1791,21 @@ /* Image resource block. */ + res_extra = 28; /* 0x03EB */ profile=GetImageProfile(image,"8bim"); if (profile == (StringInfo *) NULL) - (void) WriteBlobMSBLong(image,0); + WriteBlobMSBLong(image, res_extra); else { - (void) WriteBlobMSBLong(image,(unsigned long) GetStringInfoLength( - profile)); + (void) WriteBlobMSBLong(image,(unsigned long) res_extra + + GetStringInfoLength(profile)); (void) WriteBlob(image,GetStringInfoLength(profile),GetStringInfoDatum( profile)); } + WriteResolutionInfo(image); + + compute_layer_info: layer_count = 0; layer_info_size = 2; _______________________________________________ Magick-developers mailing list Magick-developers@imagemagick.org http://studio.imagemagick.org/mailman/listinfo/magick-developers