Answer the question
In order to leave comments, you need to log in
How to reduce RAM consumption when resizing a photo?
there is a site on yii2. There is an extension. which uses GD and resizes pictures. Faced a problem. With a photo size of about 3 mb - there is not enough RAM.
Resizing goes in several stages. An original and 3 miniatures are created.
How to bypass it? There are developments? Ideas? Offers?
Answer the question
In order to leave comments, you need to log in
In GD, RAM consumption directly depends on the number of pixels. How much the picture weighs in this case - it does not matter.
If your host has imagemagick, use it.
imagemagick has a lot of features, but the quality of the documentation is lame (or I didn't find it).
Here's a simple wrapper for you: pastebin.com/PF9j5wWF
Usage example:
$img = new SimpleImagick($original_fullpath);
$img->resizeDownTo(256, 256);
$img->save($thumb_fullpath, IMAGETYPE_JPEG, 100);
I recommend using more efficient engines instead of gd, for example, VKontakte uses Gmagick - a more efficient fork of imagick
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question