Hi Merlin, that is very fast for 1024 images, you will not get much
more speed if you try doing anything smarter ,
though there are some image libraries that are faster than GD libs eg
www.imagemagick.org
On Nov 8, 2007, at 5:13 PM, Merlin wrote:
Hi there,
I need to manipulate images on the fly. My goal is to make the image
very bright, or to add a sepia effect. The problem is, that this
takes a lot of computing power on 1024 pictures. About 2s on my
server until the image is delivered.
Does anybody know a high performing image funtion that would allow
me to brighten up the picture on the fly, or any other effect
similar to it?
I am attaching the sepia function I am using.
Thank you for any help or suggestion on how to solve that.
Best regards,
Merlin
function image_effect_sepia($im){
$start_red = 2; //red scale at black
$start_blue = 2.3; //blue scale at black
$red_scale = ($start_red-1)/256; //red modifier
as greyscale goes to white
$blue_scale = ($start_blue - 1)/256; //ditto for blue
//build a sepia lookup table
$sepia = array();
for($x = 0;$x < 256;$x++){
$red = intval($x * ($start_red - ($x * $red_scale)));
if($red > 255) $red = 255;
$blue = intval($x / ($start_blue - ($x * $blue_scale)));
$sepia[$x][0] = $red;
$sepia[$x][1] = $blue;
}
# modify the image
for($y = 0;$y < imagesy($im);$y++){
for($x = 0;$x < imagesx($im);$x++){
$pixel = imagecolorat($im, $x, $y);
$red = ($pixel & 0xFF0000) >> 16;
$green = ($pixel & 0x00FF00) >> 8;
$blue = $pixel & 0x0000FF;
$alpha = $pixel & 0x7F000000;
//get a greyscale value
$gs = intval(($red * 0.3) + ($green * 0.59) + ($blue *
0.11));
$p = $alpha | $sepia[$gs][1] | ($gs << 8) | ($sepia[$gs]
[0] << 16);
imagesetpixel ($im, $x, $y, $p);
}
}
# return the moddifyed image
return $im;
}
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Bojan Tesanovic
http://www.classicio.com/