Using imagecreatefromJpeg

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
bytte
Forum Commoner
Posts: 75
Joined: Sun Nov 23, 2003 8:20 am
Location: Belgium

Using imagecreatefromJpeg

Post 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?
User avatar
onion2k
Jedi Mod
Posts: 5263
Joined: Tue Dec 21, 2004 5:03 pm
Location: usrlab.com

Post by onion2k »

If you're using GD2.. you might try imagecopyresampled() ?
bytte
Forum Commoner
Posts: 75
Joined: Sun Nov 23, 2003 8:20 am
Location: Belgium

Post by bytte »

It is GD2.0.12

Does imagecopyresampled() do the same thing as imagecreatefromjpeg?
User avatar
onion2k
Jedi Mod
Posts: 5263
Joined: Tue Dec 21, 2004 5:03 pm
Location: usrlab.com

Post 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.
User avatar
Joe
Forum Regular
Posts: 939
Joined: Sun Feb 29, 2004 1:26 pm
Location: UK - Glasgow

Post by Joe »

If you cannot find a solution you could use CSS to create an image border :O) - Just a thought.
bytte
Forum Commoner
Posts: 75
Joined: Sun Nov 23, 2003 8:20 am
Location: Belgium

Post 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.
Post Reply