Page 1 of 1

Appending multiple png files causes large relative file size growth

Posted: 2016-03-22T10:33:26-07:00
by BadLander
I am trying to append multiple png's into a single large image with the following command:

convert -append *.png bigtest.png

This works and concatenates the png images together in an up and down manner (which is what I am looking for). The problem is that the resulting file is 249.9KB while the 4 source tiles total 47.8KB. I want as few (or preferably no changes), made to the images as they are concatenated. Running identify against the images yields the following changes:

original image(s):
Compression: JPEG
Quality: 90

resulting image:
Compression: Zip

I have tried a number of commands to override the compression setting of convert, without success. The montage command seems to handle similarly. Any ideas on what I am doing wrong? If you need more details or an example image... please speak up. Thx in advance

IM version = 6.8.9-9
Libpng version = 1.2.50
Zlib version = 1.2.8

Re: Appending multiple png files causes large relative file size growth

Posted: 2016-03-22T10:56:01-07:00
by snibgo
As far as I know, IM cannot write png files with jpeg compression. If you want jpeg compression, either write to a jpg file, or to a tiff with "-compress jpeg".

Re: Appending multiple png files causes large relative file size growth

Posted: 2016-03-22T11:03:59-07:00
by fmw42
convert -append *.png bigtest.png
FYI, proper IM 6 syntax has the input images first, then the function, then the output. But this likely will not matter. See http://www.imagemagick.org/Usage/basics/#why

I agree with user snibgo. See http://www.imagemagick.org/script/comma ... hp#quality for types of compression and quality settings for png. I believe PNG uses LZW compression. Tiff or JPG can use JPG compression.

Try using PNG8: for output, for smaller size

Code: Select all

convert *.png -append PNG8:bigtest.png

Re: Appending multiple png files causes large relative file size growth

Posted: 2016-03-22T12:11:00-07:00
by BadLander
I tried the approach with the PNG8 output and the image color washed out. The main goal here is to get these images assembled into a much larger image with minimum loss and file size gain. I am not limited to png files at this point. Any thoughts on how to accomplish this? Many thanks for your assistance...

Re: Appending multiple png files causes large relative file size growth

Posted: 2016-03-22T12:16:13-07:00
by snibgo
My page "Outputs: speed and size" may provide some guidance.

If you upload sample images, perhaps we can be more specific.

Re: Appending multiple png files causes large relative file size growth

Posted: 2016-03-22T13:15:21-07:00
by BadLander
I have run quite a number tests on the images I have. At first I didn't want to use jpeg compression (due to potential loss from re-compression), but after a real close look, I have determined that its minimal to not perceivable in this instance. Lets call this one closed. Thanks for everyones help!

Re: Appending multiple png files causes large relative file size growth

Posted: 2016-03-23T09:57:38-07:00
by glennrp
BadLander wrote:I am trying to append multiple png's into a single large image...
Running identify against the images yields the following changes:

original image(s):
Compression: JPEG
Quality: 90
Apparently your input images were in fact JPEGs not PNGs, that happened to incorrectly have the .png extension. Your output from "convert" is a PNG, which unsurprisingly has a larger file size. So your best solution, which you have already discovered, is to write the output as a JPEG. Use the same quality (90) as the input flles, to avoid excessive quality loss.