Page 1 of 1

Using imagecreatefromJpeg

Posted: Thu Dec 23, 2004 7:34 am
by bytte
Hi, I'm using ImageCreateFromJpeg to construct a thumbnail:

Code: Select all

$img_resized = ImageCreateTrueColor($img_new_width, $img_new_height);
$img_resized2 = ImageCreateTrueColor($img_new_width2, $img_new_height2);
imagecopyresized($img_resized, ImageCreateFromJpeg($_FILESї'imagefile']ї'tmp_name']),
0 , 0 , 0 , 0, $img_new_width, $img_new_height, $img_orig_width, $img_orig_height);
imagecopyresized($img_resized2, ImageCreateFromJpeg($_FILESї'imagefile']ї'tmp_name']),
0 , 0 , 0 , 0, $img_new_width2, $img_new_height2, $img_orig_width, $img_orig_height);
$img_name = "gr_$image_stored";
$img_name2 = "tn_$image_stored";
Imagejpeg($img_resized, "$IMG_ROOT/$img_name", "100");
Imagejpeg($img_resized2, "$IMG_ROOT/$img_name2", "100");

However, the thumbnails that are created SOMETIMES have an ugly border around them, on 2 sides. Not everytime though. This is an example:
Image

Does anyone have any idea how to create the thumbnail without the ugly border?

Posted: Thu Dec 23, 2004 9:32 am
by onion2k
If you're using GD2.. you might try imagecopyresampled() ?

Posted: Thu Dec 23, 2004 9:34 am
by bytte
It is GD2.0.12

Does imagecopyresampled() do the same thing as imagecreatefromjpeg?

Posted: Thu Dec 23, 2004 1:41 pm
by onion2k
bytte wrote:It is GD2.0.12

Does imagecopyresampled() do the same thing as imagecreatefromjpeg?
No, it does the same thing as imagecopyresized(). I suspect thats the issue, not the opening of the jpeg.

Posted: Thu Dec 23, 2004 1:55 pm
by Joe
If you cannot find a solution you could use CSS to create an image border :O) - Just a thought.

Posted: Sat Dec 25, 2004 6:12 pm
by bytte
onion2k wrote:If you're using GD2.. you might try imagecopyresampled() ?
Damn. It seems to work. Is there an explanation why this one works and the other one does strange things?
I didn't test it extensively, but the first images were good.