image_optimizer ()

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.

Example 1

require './includes/user_init.php';

$img = image_optimizer ('./public/image/fman.png',
'./public/image/fman_small.png', 0, 250);
if ($img) echo 'Success'; else 'Failed!';

Posted On: Aug-26-2010 @ 07:00am
Last Updated: Jan-01-1970 @ 07:00am

There is no comment. Why not be the first?

More Comments/Post Your Own


Latest Comments

  • Guest on Forum
    “noFollow links.” - Jun 19
  • username on Forum
    “Sponsor or Premium user” - Jun 14
  • on Forum
    “Template not found! contact webmaster” - Feb 24
  • admin on 01. Administration Panel
    “Untitled” - Jan 24
  • on 01. Administration Panel
    “Can't Login to Admin” - Jan 23

Most Commented

Online Users

There are 146 users online.


Connect with us on Facebook


Subscribe to our newsletter for the latest updates and exciting promotions!