Setting PNG output to 24-bit color

PerlMagick is an object-oriented Perl interface to ImageMagick. Use this forum to discuss, make suggestions about, or report bugs concerning PerlMagick.
Post Reply
johnfl68
Posts: 33
Joined: 2012-07-09T18:31:26-07:00
Authentication code: 13

Setting PNG output to 24-bit color

Post by johnfl68 » 2012-10-19T15:38:52-07:00

Hello all:

I have been looking around, and not really finding the right answer yet.

I have PNG's that are being dynamically created every hour, and they are coming out as 64-bit PNG's.

They do have transparencies in them, as part of the image creation, right now I do not need the transparencies in the final output of image (though maybe in the future).

So I want to output the final composition as a 24-bit PNG. Or as a 32-bit PNG (24-bit plus 8-bit alpha) for future use.

Any help in how to output in these formats using Perl would be greatly appreciated.

Thanks!

John

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

Re: Setting PNG output to 24-bit color

Post by fmw42 » 2012-10-19T16:10:23-07:00

In command line you can use -depth 8 to make the output 32bit rather than 64bit. You can get rid of transparency by adding -alpha off or +matte. Also see

http://www.imagemagick.org/script/comma ... .php#depth
http://www.imagemagick.org/script/comma ... .php#alpha
http://www.imagemagick.org/Usage/masking/#alpha
http://www.imagemagick.org/Usage/formats/#png


Sorry I do not know the equivalent in Perlmagick, but see alpha and matte image attributes and depth attribute at

http://www.imagemagick.org/script/perl-magick.php

johnfl68
Posts: 33
Joined: 2012-07-09T18:31:26-07:00
Authentication code: 13

Re: Setting PNG output to 24-bit color

Post by johnfl68 » 2012-11-21T11:32:57-07:00

Ok, after much searching, I found it.

You add png24: before the filename:

Code: Select all

$image->Write(filename => "png24:sample.png");
John

Post Reply