Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to speed up image resizing in a CodeIgniter PHP application?
    primarykey
    data
    text
    <p>I have an application that allows users to upload images. The test case I use is a jpeg of 1.6MB with dimensions 3872 x 2592px. The upload script in the back-end will resize the uploaded image into 6 additional formats:</p> <ul> <li>square (small 75 x 75)</li> <li>Small Thumb (50 x 38)</li> <li>Thumb (100 x 76)</li> <li>Small (240 x 161)</li> <li>Medium (500 x 378)</li> <li>Large (1024 x 774)</li> </ul> <p>I know it's a lot but trust me, I need this. I do the resizing using Code Igniter's Image Manipulation class, which uses either GD, GD2 or ImageMagick to do the resizing. I first configured it to use GD2 and noticed that the total resize process takes 11 secs.</p> <p>Since the user has to wait for this process, it is not acceptable. After a lot of reading I learned that ImageMagick is a much faster and efficient manipulation library, so I switched to that:</p> <pre><code>$sourceimage = $data['filedata']['file_path'] . $data['imagedata']['user_id'] . "/" . $imageid . $data['filedata']['file_ext']; $resize_settings['image_library'] = 'imagemagick'; $resize_settings['library_path'] = '/usr/bin'; $resize_settings['source_image'] = $sourceimage; $resize_settings['maintain_ratio'] = false; $resize_settings['quality'] = "100%"; $this-&gt;load-&gt;library('image_lib', $resize_settings); </code></pre> <p>Much to my surprise, the resize process now takes longer: 15 secs to be specific.</p> <p>Having a look at my log I see that each resize action takes 2 seconds, no matter the file format it is resizing to. I guess this is because I always resize from the original, which is very large. </p> <p>I would hate to offload the resizing process to a scheduled process, because that would decrease the usability of the site. It would mean that users have to wait a few minutes before they can start seeing/working with the image.</p> <p><strong>So, are there any smart ways to dramatically speed up this resizing process so that I can keep it in real-time? Just be clear: allowing for smaller resolutions is not an option, this is a photography site I'm building. Also, I really need the six formats mentioned.</strong></p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload