A
A
Alexander2016-08-29 16:17:26
PHP
Alexander, 2016-08-29 16:17:26

How to speed up Imagick::compositeImage?

The task is the following - there are 10 transparent png 1300*1600. I need to superimpose them sequentially on top of each other, and reduce the resulting image to a certain size. First I did this without using imagick:
1. Created an empty image $thumb = imagecreatetruecolor();
2. Opened each png one by one with $img=imagecreatefrompng() and added it to $thumb with imagecopy();
3. Resized via imagecopyresampled();
But the image quality after imagecopyresampled() was average. So I decided to resort to imagick, and did this:
$img = new Imagick();
$img->readImage('first png');
then I overlay the images in a loop:
$image2 = new Imagick();
$image2->readImage('png');
$img->compositeImage($image2, Imagick::COMPOSITE_OVER, 0, 0);
resize:
$img->resizeImage('width', 'height', imagick::FILTER_LANCZOS,1);
The quality has become excellent, but the time of the script has increased. It turned out that most of the time is occupied by overlaying images on top of each other through compositeImage();
QUESTION #1: Is there any way to speed up compositeImage()? In principle, I can overlay pictures on top of each other as before through:
2. Opened each png one by one with $img=imagecreatefrompng() and added it to $thumb with imagecopy();
but then QUESTION #2: how can I open $thumb created via imagecreatetruecolor() in imagick?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
shagguboy, 2016-08-29
@shagguboy

1) no. get console apps.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question