Hi
I needed to convert an image from 8-bit_TrueColorTypeMatte to
8-bit_TrueColorType using ImageMagick-6.3.6-2-Q16 and MagickWandForPHP on
Mandrake 2006 with PHP 5.0.4 (cli).
This posed problems as the output became 16 bit no matter what.
Further Identify kept on telling me that it was in fact 8-bit! This would
not really be possible given the resulting file sizes and that ACDSee
reported 16 bit.
If one does not do the Resize, then it works... As in Identify still claims
8-bit, but now file sizes and ACDSee agreees.
This is the code I used.
<?
$wand=NewMagickWand();
if (!IsMagickWand($wand)) {print 'Unable to create wand.';
exit(1);}
$inpath='/data/8-bit_TrueColorTypeMatte.png'; // <-
zip compressed
$outpath='/data/8-bit_TrueColorType.png';
// Read image
if (!MagickReadImage($wand, $inpath)) {print 'Unable
to read the file '.$inpath; exit(1);}
// Get rid of Matte
if (!MagickSetImageType($wand, MW_TrueColorType))
{print 'Unable to get rid of matte'; exit(1);}
// Resize to 1920x1080
if (!MagickResizeImage($wand, 1920, 1080,
MW_GaussianFilter, 1)) {print 'Unable to resize to 1920x1080.'; exit(1);}
// Bit depth 8 bit
if (!MagickSetImageDepth($wand, 8)) {print 'Unable
to set colordepth to 8'; exit(1);}
// Try changing compression
if (!MagickSetImageCompression($wand,
MW_NoCompression)) {print 'Unable to set compression'; exit(1);}
// Write image
if (!MagickWriteImage($wand, $outpath)) {print
'Unable to write the file ['.$outpath.']'; exit(1);}
DestroyMagickWand($wand);
?>
To be absolutely sure that the file sizes would tell me about 8 or 16 bit, I
tried to change the compression... It always succedes, but the file is still
zip compressed (according to Identify that is). Perhaps NoCompression isn't
supported by png, but I would think that if WriteImage wasn't able to honour
the settings of the image, it should fail (as it does not do what it was
requested to do...)... Well perhaps that's too strict...
Finally I had to revert to 6.3.5-10 Q8, but that's not really what I want,
and in any event it should work!
Am I doing something wrong? Should I do something to truncate the channels
to 8-bit, other than just setting them to 8-bit?
Any ideas?
Best regards
HC
_______________________________________________
Magick-bugs mailing list
[email protected]
http://studio.imagemagick.org/mailman/listinfo/magick-bugs