Page 1 of 1

Problem composite huge images

Posted: 2011-02-03T04:13:57-07:00
by Franzose
Hey,

its my first contact with imagemagick so i think this problem is my fault.

Problem: I had to composite some huge images to one big one as a artwork master.

If the source images are not to big. Everything works fine.
But if they are to big (jpeg 12533x8333 ~7MB) imagemagick stops working with no result image.

I work with temp images in a folder on a webserver. After all i delete everything except the result PDF-File.

And now how i handle everything... inside a php-script

First step: create a new image

Code: Select all

$page_path  = $globalvar['filepathEditorTemp'].$product_id.'_page_'.$k_p.'.png';
			
$command = "  convert -size ".$width_article."x".$height_article." -density ".$v_a->n_article_dpi."x".$v_a->n_article_dpi." xc:".$v_p->s_backColor." ".$page_path;

exec($command);
Second step: create another new image

Code: Select all

$box_path = $globalvar['filepathEditorTemp'].$product_id.'_box_'.$k_b.'.png';

$command = "convert -size ".$width."x".$height." -density ".$v_a->n_article_dpi."x".$v_a->n_article_dpi." xc:".$v_b->s_backColor." ".$box_path;

exec($command);
Third step: open a huge source image and resize it -> at this point imagemagick stops often stops working and goes on with the next steps

Code: Select all

$trans_path = $globalvar['filepathEditorTemp'].$product_id.'_trans_'.$k_b.'.png';

$command = "convert -geometry ".$t_width."x".$t_height." -density ".$v_a->n_article_dpi."x".$v_a->n_article_dpi." ".$source_image."  ".$trans_path;
					
exec($command);
Fourth step: Composite resized source-image with box-image

Code: Select all

$command = "composite -geometry ".$t_left.$t_top." ".$trans_path."   ".$box_path."  ".$box_path;
exec($command);
Sixth step: Composite box-source-image with page-image

Code: Select all

$command = "composite -geometry ".$left.$top." ".$box_path."    ".$page_path."  ".$page_path;
exec($command);
Last step: Save it as pdf-File -> works mostly with no problems

Code: Select all

$command = "composite -geometry ".$left.$top." ".$box_path."    ".$page_path."  ".$page_path;
exec($command);
So can anyone give me an solution how i can fix it and optimize my commands?

Thanks a lot

Greeting Bernd

Re: Problem composite huge images

Posted: 2011-02-03T06:39:34-07:00
by magick
Add -limit area 0 to your command line (right after the convert keyword). That will reduce the memory requirements. You still need to assure you have plenty of temporary disk space.

To trace the execution of an ImageMagick command, add -debug all to the command line.

PHP has limits. Check php.ini and adjust the limits to ensure large images are handled properly by PHP.

Re: Problem composite huge images

Posted: 2011-02-09T03:13:42-07:00
by Franzose
Thanks a lot.
Now i can create images with >20 MB file size.

And now a other question.

It is possible to raise the execution time of this step?

Code: Select all

$trans_path = $globalvar['filepathEditorTemp'].$product_id.'_trans_'.$k_b.'.png';

$command = "convert -geometry ".$t_width."x".$t_height." -density ".$v_a->n_article_dpi."x".$v_a->n_article_dpi." ".$source_image."  ".$trans_path;
               
exec($command);
It needs a lot of the whole execution time of the script, if i extend the source image.