print

image_optimizer ()

You are here: C97net5.08 Image Functions

Optimize an image

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

<?php
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 at 07:00am
Last Updated: Jan-01-1970 at 07:00am

There is no comment. Why not be the first?

read more More Comments/Post Your Own

Account

Search

Tags

acp add all also any create default display don download easy echo etc features field file files folder form function includes information init kemana link list may module name need number own page php please qengine read require script set site skin time tpl url use user using version welcome