|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
AT&T devCentral & BlackBerry(r) Webcast Series: BlackBerry and GPS -Build Location Awareness into your BlackBerry Applications, July 10th-1:00PM EST. Register Today!
|
|
#1
|
|||
|
|||
|
thumbnails tutorial
I have just started to look at trying to create a thumb nail image from the tutorial from the M. Bailey, but as I tried to run it I ahve recieved a parse error. As I have just pasted and copies from page I can;t understand .
here is code php code------- <?php # Constants define(IMAGE_BASE, '/main'); define(MAX_WIDTH, 150); define(MAX_HEIGHT, 150); # Get image location $image_file = str_replace('..', '', $_SERVER['QUERY_STRING']); ----------line above is offending code -parse error--------------------- $image_path = IMAGE_BASE."/$image_file"; # Load image $img = null; $ext = strtolower(end(explode('.', $image_path))); if ($ext == 'jpg' || $ext == 'jpeg') { Â*Â*Â*Â*$img = @imagecreatefromjpeg($image_path); } else if ($ext == 'png') { Â*Â*Â*Â*$img = @imagecreatefrompng($image_path); # Only if your version of GD includes GIF support } else if ($ext == 'gif') { Â*Â*Â*Â*$img = @imagecreatefrompng($image_path); } # If an image was successfully loaded, test the image for size if ($img) { Â*Â*Â*Â*# Get image size and scale ratio Â*Â*Â*Â*$width = imagesx($img); Â*Â*Â*Â*$height = imagesy($img); Â*Â*Â*Â*$scale = min(MAX_WIDTH/$width, MAX_HEIGHT/$height); Â*Â*Â*Â*# If the image is larger than the max shrink it Â*Â*Â*Â*if ($scale < 1) { Â*Â*Â*Â*Â*Â*Â*Â*$new_width = floor($scale*$width); Â*Â*Â*Â*Â*Â*Â*Â*$new_height = floor($scale*$height); Â*Â*Â*Â*Â*Â*Â*Â*# Create a new temporary image Â*Â*Â*Â*Â*Â*Â*Â*$tmp_img = imagecreatetruecolor($new_width, $new_height); Â*Â*Â*Â*Â*Â*Â*Â*# Copy and resize old image into new image Â*Â*Â*Â*Â*Â*Â*Â*imagecopyresized($tmp_img, $img, 0, 0, 0, 0, Â*Â*Â*Â*Â*Â*Â*Â*Â*Â*Â*Â*Â*Â*Â*Â*Â*Â*Â*Â*Â*Â*Â*Â*Â* $new_width, $new_height, $width, $height); Â*Â*Â*Â*Â*Â*Â*Â*imagedestroy($img); Â*Â*Â*Â*Â*Â*Â*Â*$img = $tmp_img; Â*Â*Â*Â*} } # Create error image if necessary if (!$img) { Â*Â*Â*Â*$img = imagecreate(MAX_WIDTH, MAX_HEIGHT); Â*Â*Â*Â*imagecolorallocate($img,0,0,0); Â*Â*Â*Â*$c = imagecolorallocate($img,70,70,70); Â*Â*Â*Â*imageline($img,0,0,MAX_WIDTH,MAX_HEIGHT,$c 2); Â*Â*Â*Â*imageline($img,MAX_WIDTH,0,0,MAX_HEIGHT,$c 2); } # Display the image header("Content-type: image/jpeg"); imagejpeg($img); ?> php--------- can anyone hlep me to sought it out as `I cant find error |
![]() |
| Viewing: Codewalkers Forums > Other > Tutorials > thumbnails tutorial |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|
|