convert creates too large files

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
Greg Coats
Posts: 31
Joined: 2004-10-28T11:18:28-07:00
Location: Virginia, USA

Post by Greg Coats »

Because you are using IM Q16, and not telling convert to use -depth 8 when creating the output file, IM is creating the output file with 16 bits per color channel, hence its file size is larger than the 8 bits per color channel input file.
$ convert -version
Version: ImageMagick 6.2.6 03/26/06 Q16 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2006 ImageMagick Studio LLC

$ convert highres.png -resize 950x1344! lowres.png
$ ls -lf highres.png lowres.png
-rw-r--r-- 1 gregcoat wheel 689721 May 6 00:15 highres.png
-rw-r--r-- 1 gregcoat gregcoat 984698 May 6 00:21 lowres.png
$ file highres.png lowres.png
highres.png: PNG image data, 2479 x 3508, 8-bit/color RGBA, non-interlaced
lowres.png: PNG image data, 950 x 1344, 16-bit/color RGBA, non-interlaced

$ convert highres.png -resize 950x1344! -depth 8 lowres.png
$ ls -lf highres.png lowres.png
-rw-r--r-- 1 gregcoat wheel 689721 May 6 00:15 highres.png
-rw-r--r-- 1 gregcoat gregcoat 515817 May 6 00:26 lowres.png
$ file highres.png lowres.png
highres.png: PNG image data, 2479 x 3508, 8-bit/color RGBA, non-interlaced
lowres.png: PNG image data, 950 x 1344, 8-bit/color RGBA, non-interlaced
Greg Coats
Posts: 31
Joined: 2004-10-28T11:18:28-07:00
Location: Virginia, USA

Post by Greg Coats »

Your originally objective was to have ImageMagick save the output file as a PNG, but you were saving the PNG with 16 bits for each color channel, even though the input was only 8 bits per color channel. Now you are using Photoshop to save the output file as a GIF, and complaining that the PNG and the GIF are not the same size. Of course, the GIF and the PNG are not the same. GIF is a lossy compression that supports only 256 colors, while PNG is a lossless compression supporting 16,777,216 colors. That is a big difference.
You also wrongly claim that Photoshop requires 264KB to save the GIF. In fact, both Photoshop and ImageMagick save the lowres file as a 26KB GIF, 10% of the file size you claim Photoshop needs.
convert highres.png -resize 950x1344! -depth 8 lowres.gif
highres.png 689721 bytes
lowres.gif 26484 bytes
Post Reply