For Programmers: Free Programming Magazines  


Home > Archive > PHP Language > March 2006 > imagecopyresampled green color only









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author imagecopyresampled green color only
Jean Pierre Daviau

2006-03-30, 7:57 am

Hi to every one and yes, me again,

I done a working script, would you believe?

http://jeanpierredaviau.com/news/titimg.php


But although the original image has lot of red, the resampled image is
green only.
-----------------
$inImg = "a.jpg";

$max_width = 200;
$max_height = 150;

$size = GetImageSize($inImg);
$width = $size[0];
$height = $size[1];

$x_ratio = $max_width / $width;
$y_ratio = $max_height / $height;

if ( ($width <= $max_width) && ($height <= $max_height) ) {
$tn_width = $width;
$tn_height = $height;
}
else if (($x_ratio * $height) < $max_height) {
$tn_height = ceil($x_ratio * $height);
$tn_width = $max_width;
}
else {
$tn_width = ceil($y_ratio * $width);
$tn_height = $max_height;
}

$src = ImageCreateFromJpeg($inImg);
$dst = ImageCreate($tn_width, $tn_height);

imagecopyresampled($dst, $src, 0, 0, 0, 0, $tn_width, $tn_height, $width,
$height);
ImageFilter($dst, IMG_FILTER_CONTRAST, -10);

//header("Content-type: image/jpg");
ImageJpeg($dst, "mini.jpg", 75);
ImageDestroy($src);
ImageDestroy($dst);
----------------------------
Thanks for your attention.

Jean Pierre Daviau
--
Easyphp1.8
Apache1.3.24
DEVC++, borland 5.5
windows Xp
asus p4 s533/333/133
Intel(R) Celeron (R) CPU 2.00 GHz
http://www.jeanpierredaviau.com


Jean Pierre Daviau

2006-03-30, 6:57 pm

solved with this line:
$thumb = @imagecreatetruecolor ($tn_width, $tn_height) or die ("flux d'image
GD impossible");


Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com