Appending multiple png files causes large relative file size growth

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
BadLander
Posts: 3
Joined: 2016-03-22T08:00:23-07:00
Authentication code: 1151

Appending multiple png files causes large relative file size growth

Post 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
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

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

Post 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".
snibgo's IM pages: im.snibgo.com
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

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

Post 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
BadLander
Posts: 3
Joined: 2016-03-22T08:00:23-07:00
Authentication code: 1151

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

Post 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...
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

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

Post by snibgo »

My page "Outputs: speed and size" may provide some guidance.

If you upload sample images, perhaps we can be more specific.
snibgo's IM pages: im.snibgo.com
BadLander
Posts: 3
Joined: 2016-03-22T08:00:23-07:00
Authentication code: 1151

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

Post 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!
User avatar
glennrp
Posts: 1147
Joined: 2006-04-01T08:16:32-07:00
Location: Maryland 39.26.30N 76.16.01W

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

Post 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.
Post Reply