I have a website where users can upload images. I process these images directly and resize them in 5 additional formats using the CodeIgniter Image Manipulation class. I am doing this quite efficiently, as follows:
- I always resize from the previous format, not from the original
- I resize the image with 90% image quality, which reduces the jpegs file size by about half
The above way of doing what I implemented after I advised, received from another question that I asked. My test case is 1.6 MB JPEG in RGB mode with a high resolution of 3872 x 2592. For this image, which is a kind of borderline case, the process of resizing as a whole takes about 2 seconds, which is acceptable for me.
Now only one challenge remains. I want the source file to be compressed using this 90% quality, but without changing it. The idea is that this file will also take half the size of the file. I decided that I could just resize it to its current size, but that doesn't look like a file or its size. Here my code is somewhat simplified:
$sourceimage = "test.jpg";
$resize_settings['image_library'] = 'gd2';
$resize_settings['source_image'] = $sourceimage;
$resize_settings['maintain_ratio'] = false;
$resize_settings['quality'] = '90%';
$this->load->library('image_lib', $resize_settings);
$resize_settings['width'] = $imagefile['width'];
$resize_settings['height'] = $imagefile['height'];
$resize_settings['new_image'] = $filename;
$this->image_lib->initialize($resize_settings);
$this->image_lib->resize();
, . CI-, , , , script , . , . , , .
- , ( , jpeg) 90%, CI ?