Neverland
Neverland

Reputation: 775

Calculate the main memory consumption of ImageMagick convert when appending images

I append several PNG images with the ImageMagick convert tool.

convert -set colorspace RGB `ls *.png` -append outout.png

This are the color parameters of the input files:

$ identify input1.png
input1.png PNG 9600x1800 9600x7200+0+0 8-bit sRGB 355KB 0.000u 0:00.000

4 input files exist with identical parameters.

The output file has these color parameters:

$ identify output.png
output.png PNG 9600x7200 9600x28800+0+0 8-bit sRGB 2.461MB 0.000u 0:00.009

This is the ImageMagick version I use:

$ convert -version 
Version: ImageMagick 6.7.7-10 2014-04-09 Q16 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2012 ImageMagick Studio LLC
Features: OpenMP    

How can I calculate the main memory consumption of the convert ... -append operation?

Upvotes: 2

Views: 755

Answers (1)

dlemstra
dlemstra

Reputation: 8143

It seems you are using the Q16 version of ImageMagick and this version of ImageMagick uses 16 bits per pixel channel (The Q8 version uses 8 bits per pixel). In ImageMagick 6 each pixel has 4-5 channels per pixel (red,green,blue,opacity, index), this behavior is going to change in ImageMagick 7 (http://www.imagemagick.org/script/porting.php#channels). Since your input and output are both a png file you are using 4 channels per pixel, this totals to 16*4 = 64 bits per pixel. Because your input images are 9600x1800 and you are combining 4 of them into a single image you will need a total of 64*9600*1800*4 = 4423680000 bits / 552.96 MB to allocate the images in memory. But because a copy of each image is created when the output image is created you will need twice that amount of memory: 1.1 GB.

Upvotes: 4

Related Questions