On-the-fly thumbnails PHP

Posted by Wayne on Stack Overflow See other posts from Stack Overflow or by Wayne
Published on 2010-05-30T20:02:29Z Indexed on 2010/05/30 20:12 UTC
Read the original article Hit count: 248

I came up with this:

<?php 

$dir = $_GET['dir'];

header('Content-type: image/jpeg'); 

$create = imagecreatetruecolor(150, 150); 
$img = imagecreatefromjpeg($dir); 
imagecopyresampled($create, $img, 0, 0, 0, 0, 150, 150, 150, 150); 

imagejpeg($create, null, 100); 

?>

It works by accessing:

http://domain.com/image.php?dir=thisistheimage.jpg

Which works fine... but the output is awful:

alt text

Can someone fix my code for the image to be 150 x 150 covering the black area...

Thanks.

© Stack Overflow or respective owner

Related posts about php

Related posts about image-processing