thumbnail creator problems
Posted: Thu Aug 30, 2007 11:32 pm
I have been looking for a simple bit of code that will allow me to use any image already uploaded and resize it down to a small thumbnail. I have found a lot, but this code seems to be as closest to what I want.
the only problem is that when I execute it I get these two errors:
Warning: getimagesize() [function.getimagesize]: URL file-access is disabled in the server configuration in /home/public_html/path/thumbnail.php on line 7
Warning: getimagesize(http://www.mysite.com/images/image.jpg) [function.getimagesize]: failed to open stream: no suitable wrapper could be found in /home/public_html/path/thumbnail.php on line 7
Code: Select all
// Get image info from variable
$url = $_GET['url'];
$img = getimagesize($url);//line 7
// Checks if URL is image
if ( $img[2] == 1 ) {
$pic = imagecreatefromgif( $url ) or die();
} elseif ( $img[2] == 2 ) {
$pic = imagecreatefromjpeg( $url ) or die();
} elseif ( $img[2] ==3 ) {
$pic = imagecreatefrompng( $url ) or die();
} else {exit();}
// If an image is found and we can determine that it is an image
if ($pic) {
// Get width and height from the image
$width = imagesx($pic);
$height = imagesy($pic);
$theight = 100;
// Calculate the new width
$twidth = ($theight * $width) / $height;
// Create new image
$thumb = @imagecreatetruecolor ( $twidth, $theight )
or die ("Can't create Image!");
// Resize the image into a thumb
imagecopyresized($thumb, $pic, 0, 0, 0, 0,
$twidth, $theight, $width, $height);
// Change page type to a jpeg
header ("Content-type: image/jpeg");
// Create jpeg image from thumbnail
imagejpeg($thumb,"",75);
} else {exit();}Warning: getimagesize() [function.getimagesize]: URL file-access is disabled in the server configuration in /home/public_html/path/thumbnail.php on line 7
Warning: getimagesize(http://www.mysite.com/images/image.jpg) [function.getimagesize]: failed to open stream: no suitable wrapper could be found in /home/public_html/path/thumbnail.php on line 7