2

How to convert 32bit PNG file to 24bit PNG file using PHP.

btw I am using Codeigniter, and planning to host files at Dreamhost.

Thanks!

1 Answers1

-1

Give this a try:

exec('convert -depth 24 /path/to/old/image.png /path/to/new/image.png');

There is a PEAR package for ImageMagick, although making a system call also works if your hosting provider hasn't installed the PEAR package.

Julian H. Lam
  • 25,501
  • 13
  • 46
  • 73
  • `system('convert -depth 24 order/41/4e8e99f15be6f/png-export.png order/41/4e8e99f15be6f/png-export-24.png');`, what is strange I get this error **FPDF error: 16-bit depth not supported: order/41/4e8e99f15be6f/png-export-24.png** – Nemanja Srećković Oct 07 '11 at 18:14
  • 4
    -depth 24 is not correct. The depth refers to bits-per-sample, and you want 8 not 24. The simplest way to request RGB888 from ImageMagick is "convert old.png png24:new.png" – Glenn Randers-Pehrson Mar 28 '14 at 22:20