Tutorials
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Codewalkers ForumsOtherTutorials

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Codewalkers Forums Sponsor:
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  
Old October 18th, 2004, 01:02 PM
urbannomad urbannomad is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 1 urbannomad User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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

Reply With Quote
Reply

Viewing: Codewalkers ForumsOtherTutorials > thumbnails tutorial


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway