function image_optimizer ($source, $target, $target_q = 0, $target_x = 0,
$target_y = 0)
Use this function to optimize an image without sacrificing the quality, also known as resample. This function requires GD library version 2.x.
$source = image source file name.
$target = image target file name.
$target_q = image target quality, 1 = lowest, 100 = best, default 0, aka according to ACP > Configuration (default 80).
$target_x = image target width, optional, default to same size. You can also use 'thumb', to create thumbnail size (according to ACP > Configuration, default 100).
$target_y = image target height, optional, default to same size. You can also enter $target_x only, and leave $target_y zero, to force qE to resize by scale.
It will return true if the image succesfully resized, and false if not.
Resize By Scale
If you define $target_x, but leave $target_y empty, qE will resize the image by scale smartly. 'Smartly' because qE will calculate the image size, and will resize accordingly so either width or height is not bigger than $target_x.
For example, a 400 x 300 image, will be resized to $target_x = 100, then the resulting image size is = 100 x 75. But a 300 x 400 image, with same settings, will be resized to 75 x 100, not 100 x 133.
$img = image_optimizer ('./public/image/fman.png',
'./public/image/fman_small.png', 0, 250);
if ($img) echo 'Success'; else 'Failed!';
Subscribe to our newsletter for the latest updates and exciting promotions!