Rounded corner thumbnail [status: still not solved]

Need help with Photoshop, the GIMP, Illustrator, or others? Want to show off your work? Looking for advice on your newest Flash stuff?

Moderator: General Moderators

Dm7
Forum Commoner
Posts: 67
Joined: Sat Oct 08, 2005 9:16 pm
Location: USA

Rounded corner thumbnail [status: still not solved]

Post by Dm7 »

Hi,

It was working with resize and upload the image (everything worked)... til recently, I decided to add rounded corners for thumbnail images and I got this error...

Code: Select all

Parse error: parse error, unexpected T_STRING in /var/www/vhosts/dm7.net/httpdocs/gallery/upload.php on line 118
What did I do wrong? Notice: the line 120 in my code is...

Code: Select all

// create arc on top left corner
			imagearc($thumb, CORNER_THICKNESS, CORNER_THICKNESS, CORNER_THICKNESS, CORNER_THICKNESS, 180, 270, $lime);
Here's my code (very long... please bear with me)...

Code: Select all

<?php
#########################################
#       Admin Gallery System            #
#           upload.php                  #
#########################################
include("auth.inc.php");
include("functions_main.inc.php");
include("fields_login.inc.php");
include("gallery.css");
$table = "art";
 
if ($_GET['log'] == "yes") {
$result = "You have been already logged in!"; }

 ?>

 
<p class="style3"><?php echo $page['top'];  echo " - Today is: " . date("Y-m-d G:i:s"); ?></p>
<div align="center">You have reached "<?php echo $page['title'] ?>" uploading section!</div>
<center><?php if (isset($result)) { ?><font color="red"><?php echo $result; ?></font><?php } ?></center>

<?php
$overlay = "/var/www/vhosts/dm7.net/httpdocs/gallery/Copyright.png";
$cache_fs = "/var/www/vhosts/dm7.net/httpdocs/gallery/images/";
$cache_uri = "http://dm7.net/gallery/images/";
define('MAX_HEIGHT', 150);
define('MAX_WIDTH', 150);
define('CORNER_THICKNESS', 20);

// Checks if overlay image exists

	if (!$overlay = imagecreatefrompng($overlay)) {
		$error = "error opening overlay image";
		$show = "error";
	}
	
// sets up the path
	if (isset($_FILES['file'])) {
	
		$name = $_FILES['file']['name'];
		$base_fs = $cache_fs . $name;
		$base_fstb = $cache_fs . 'tb' . $name;
		$base_uri = $cache_uri . $name;
		$base_uritb = $cache_uri . 'tb' . $name;
		
		//open original (uploaded) image, based on type.
		switch($_FILES['file']['type']) {
			case 'image/jpeg':
			case 'image/pjpeg':
				$orig = imagecreatefromjpeg($_FILES['file']['tmp_name']);
				break;
			case 'image/png':
				$orig = imagecreatefrompng($_FILES['file']['tmp_name']);
				break;
			case 'image/gif':
				$orig = imagecreatefromgif($_FILES['file']['tmp_name']);
				break;
			default:
				$error = "Unknown File Format or MIME Type";
				$show = "error"; } 
			
			if ($orig) {
	
			
			// fetch the size of the original and overlay images,
			// and calculate the size of the new image and thumb.
				
		$width = imagesx($orig);
		$height = imagesy($orig);
		$overlay_x = imagesx($overlay);
		$overlay_y = imagesy($overlay);
		
									
			// Calculate thumbnail size to avoid distortions
			
		$imageratio_x = $width / MAX_WIDTH;
		$imageratio_y = $height / MAX_HEIGHT;
			
				if ($imageratio_x > $imageratio_y) {
					$thumb_x = MAX_WIDTH;
					$thumb_y = round($height / $imageratio_x);
				}
				if ($imageradio_x < $imageratio_y) {
					$thumb_x = round($width / $imageratio_y);
					$thumb_y = MAX_HEIGHT;
				}
				if ($imageradio_x == $imageratio_y) {
					$thumb_x = MAX_WIDTH;
					$thumb_y = MAX_HEIGHT;
				}
			
				// Calculate offsets for overlay (bottom right)
			
			$offset_x = $width - $overlay_x;
			$offset_y = 1;				
			
				// Set the transparent color in the overlay, and copy
				// it into the new image.
			imagecolortransparent($overlay);
			imagecopymerge($orig, $overlay, $offset_x, $offset_y, 0, 0, $overlay_x, $overlay_y, 75);
			
				// create the thumb image, and scale the original in it.
			$thumb = imagecreatetruecolor($thumb_x, $thumb_y);
			imagecopyresampled($thumb, $orig, 0, 0, 0, 0, $thumb_x, $thumb_y, $width, $height);	
			
				// set colors for background and rounded corners
			$black = imagecolorallocate($thumb, 0, 0, 0);
			$lime = imagecolorallocate($thumb, 0, 255, 0);
			
				// transparent
			$trans = imagecolortransparent($thumb, $lime)
			
				################################################
				#  create rounded corner image (beta version)  #
				################################################
				
				// create arc on top left corner
			imagearc($thumb, CORNER_THICKNESS, CORNER_THICKNESS, CORNER_THICKNESS, CORNER_THICKNESS, 180, 270, $lime);
			
				// create arc on top right corner			
			imagearc($thumb, ($thumb_x-CORNER_THICKNESS), CORNER_THICKNESS, CORNER_THICKNESS, 270, 0, $lime);
			
				// create arc on bottom left corner
			imagearc($thumb, CORNER_THICKNESS, ($thumb_y-CORNER_THICKNESS), CORNER_THICKNESS, CORNER_THICKNESS, 90, 180, $lime);
			
				// create arc on bottom right corner
			imagearc($thumb, ($thumb_x-CORNER_THICKNESS), ($thumb_y-CORNER_THICKNESS), CORNER_THICKNESS, CORNER_THICKNESS, 0, 90, $lime);
			
				// fill out the top edge
			imageline($thumb, CORNER_THICKNESS, 0, ($thumb_x-CORNER_THICKNESS), 0, $lime);
			
				// fill out the bottom edge
			imageline($thumb, CORNER_THICKNESS, $thumb_y, ($thumb_x-CORNER_THICKNESS), $thumb_y, $lime);
			
				// fill out the left edge
			imageline($thumb, 0, CORNER_THICKNESS, 0, CORNER_THICKNESS, $lime);
			
				// fill out the right edge
			imageline($thumb, $thumb_x, CORNER_THICKNESS, $thumb_x, ($thumb_y-CORNER_THICKNESS), $lime);
			
				// fill black bg
			imagefilltoborder($thumb, 0, 0, $lime, $black);
			imagefilltoborder($thumb, 0, $thumb_y, $lime, $black);
			imagefilltoborder($thumb, $thumb_x, 0, $lime, $black);
			imagefilltoborder($thumb, $thumb_x, $thumb_y, $lime, $black);
			
				
				
				// calculate the uri of the 2 images
			$orig_uri = $base_uri;
			$thumb_uri = $base_uritb;
			
				// Write 2 images to disk
			if(is_file($orig_uri)) {
				$show = "error";
				$error = "File already exists!";
				}
			else {		
				// write the records to database
			$datetime = date("Y-m-d G:i:s");
			$title = $_REQUEST['title'];
			$comment = $_REQUEST['comment'];
			Connect_to_db("Vars.inc.php");
			$sql = "INSERT INTO $table SET " .
					"name='$name', ".
					"image='$orig_uri', ". 
					"tbimage='$thumb_uri', " .
					"title='$title', " .
					"date='$datetime', " .
					"comment='$comment'";
			
			
			if (mysql_query($sql)) {
			 $show = "result"; }
			 else { echo "Couldn't execute query! " .  mysql_error();
			 		die(); } 
			
			imagejpeg($orig, $base_fs, 90);
			imagejpeg($thumb, $base_fstb);
			
			
			}
			}
					
	}
			
  
 ?> </p>
	<?php 
	if(isset($show)) {
		if($show == "error") { ?>
	<h2 align="center"><font color="red"><?=$error?></font></h2> <?php }
	elseif($show == "result") { ?>
	<h2 align="center">Thumb Image</h2>
	<p align="center"><img src="<?=$thumb_uri?>"/></p>
	<?php }} ?>
	   <form enctype="multipart/form-data" method="POST" action="<?php echo $_SERVER['PHP_SELF'] ?>">
  <div align="center">
    <table width="320" border="0" align="center" cellpadding="2" cellspacing="0">
      <tr>
        <td width="91">Image:</td>
        <td width="221">
		<input name="name" type="hidden" value="<?php echo $name ?>">
        <input name="file" type="file" size="30">    </td>
      </tr>
      <tr>
        <td>Title:</td>
        <td><input name="title" type="text" id="title" size="32"></td>
      </tr>
      <tr>
        <td valign="top">Comment:</td>
        <td><textarea name="comment" cols="32" rows="4" id="comment"></textarea></td>
      </tr>
      <tr>
        <td colspan="2"><div align="right">
          <input type="submit" name="submit" value="Upload">
        </div></td>
      </tr>
</table>

</form>
<center>
<?php
foreach($menulogin as $key => $value)
	{ if ($key == 'logout') {
		echo $value;
		}
	  else { echo $value . " | " ;}
	 } ?>
</center>
<p align="center"><?php echo $page['bottom']; ?></p>
Sorry, I know it's a long code, but I felt that all were necessary to help you understand what my code was doing. It did work with the tutorial that I found for rounded corner button with center text.. I tested it on the image and it worked... it's just that it all of a sudden doesn't work in my code and I can't figure out why. Any ideas? Thanks in advance. :D
Last edited by Dm7 on Sun Oct 09, 2005 6:01 pm, edited 3 times in total.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

missing a semicolon

Code: Select all

$trans = imagecolortransparent($thumb, $lime)
Dm7
Forum Commoner
Posts: 67
Joined: Sat Oct 08, 2005 9:16 pm
Location: USA

Post by Dm7 »

feyd wrote:missing a semicolon

Code: Select all

$trans = imagecolortransparent($thumb, $lime)
lol thanks.. sometimes I work on it too long that I miss a simple thing like a semicolon. How stupid of me. Now, everything works fine.. just that it was a beta version.. a lot of math errors... I'm fixing at the moment. Thank you for helping!
Dm7
Forum Commoner
Posts: 67
Joined: Sat Oct 08, 2005 9:16 pm
Location: USA

Hidding Error... other one

Post by Dm7 »

Other thing is... it works... but, whenever i change $black bg to other color, then it won't upload the image at all.

Example of working image with black bg:
Image
Visit http://dm7.net/?page=gallery to see what I mean...

The code is:

Code: Select all

<?php
#########################################
#       Admin Gallery System            #
#           upload.php                  #
#########################################
include("auth.inc.php");
include("functions_main.inc.php");
include("fields_login.inc.php");
include("gallery.css");
$table = "art";
 
if ($_GET['log'] == "yes") {
$result = "You have been already logged in!"; }

 ?>

 
<p class="style3"><?php echo $page['top'];  echo " - Today is: " . date("Y-m-d G:i:s"); ?></p>
<div align="center">You have reached "<?php echo $page['title'] ?>" uploading section!</div>
<center><?php if (isset($result)) { ?><font color="red"><?php echo $result; ?></font><?php } ?></center>

<?php
$overlay = "/var/www/vhosts/dm7.net/httpdocs/gallery/Copyright.png";
$cache_fs = "/var/www/vhosts/dm7.net/httpdocs/gallery/images/";
$cache_uri = "http://dm7.net/gallery/images/";
define('MAX_HEIGHT', 150);
define('MAX_WIDTH', 150);
define('CORNER_THICKNESS', 30);

// Checks if overlay image exists

	if (!$overlay = imagecreatefrompng($overlay)) {
		$error = "error opening overlay image";
		$show = "error";
	}
	
// sets up the path
	if (isset($_FILES['file'])) {
	
		$name = $_FILES['file']['name'];
		$base_fs = $cache_fs . $name;
		$base_fstb = $cache_fs . 'tb' . $name;
		$base_uri = $cache_uri . $name;
		$base_uritb = $cache_uri . 'tb' . $name;
		
		//open original (uploaded) image, based on type.
		switch($_FILES['file']['type']) {
			case 'image/jpeg':
			case 'image/pjpeg':
				$orig = imagecreatefromjpeg($_FILES['file']['tmp_name']);
				break;
			case 'image/png':
				$orig = imagecreatefrompng($_FILES['file']['tmp_name']);
				break;
			case 'image/gif':
				$orig = imagecreatefromgif($_FILES['file']['tmp_name']);
				break;
			default:
				$error = "Unknown File Format or MIME Type";
				$show = "error"; } 
			
			if ($orig) {
	
			
			// fetch the size of the original and overlay images,
			// and calculate the size of the new image and thumb.
				
		$width = imagesx($orig);
		$height = imagesy($orig);
		$overlay_x = imagesx($overlay);
		$overlay_y = imagesy($overlay);
		
									
			// Calculate thumbnail size to avoid distortions
			
		$imageratio_x = $width / MAX_WIDTH;
		$imageratio_y = $height / MAX_HEIGHT;
			
				if ($imageratio_x > $imageratio_y) {
					$thumb_x = MAX_WIDTH;
					$thumb_y = round($height / $imageratio_x);
				}
				if ($imageradio_x < $imageratio_y) {
					$thumb_x = round($width / $imageratio_y);
					$thumb_y = MAX_HEIGHT;
				}
				if ($imageradio_x == $imageratio_y) {
					$thumb_x = MAX_WIDTH;
					$thumb_y = MAX_HEIGHT;
				}
			
				// Calculate offsets for overlay (bottom right)
			
			$offset_x = $width - $overlay_x;
			$offset_y = 1;				
			
				// Set the transparent color in the overlay, and copy
				// it into the new image.
			imagecolortransparent($overlay);
			imagecopymerge($orig, $overlay, $offset_x, $offset_y, 0, 0, $overlay_x, $overlay_y, 75);
			
				// create the thumb image, and scale the original in it.
			$thumb = imagecreatetruecolor($thumb_x, $thumb_y);
			imagecopyresampled($thumb, $orig, 0, 0, 0, 0, $thumb_x, $thumb_y, $width, $height);	
			
				// set colors for background and rounded corners
			$black = imagecolorallocate($thumb, 0, 0, 0);
			$lime = imagecolorallocate($thumb, 62, 0, 91);
			
				################################################
				#  create rounded corner image (beta version)  #
				################################################
				
				// create arc on top left corner
			imagearc($thumb, (CORNER_THICKNESS/2), (CORNER_THICKNESS/2), CORNER_THICKNESS, CORNER_THICKNESS, 180, 270, $lime);
			
				// create arc on top right corner			
			imagearc($thumb, ($thumb_x-(CORNER_THICKNESS)/2), (CORNER_THICKNESS/2), CORNER_THICKNESS, CORNER_THICKNESS, 270, 360, $lime);
			
				// create arc on bottom left corner
			imagearc($thumb, CORNER_THICKNESS/2, ($thumb_y-(CORNER_THICKNESS/2)), CORNER_THICKNESS, CORNER_THICKNESS, 90, 180, $lime);
			
				// create arc on bottom right corner
			imagearc($thumb, ($thumb_x-(CORNER_THICKNESS/2)), ($thumb_y-(CORNER_THICKNESS/2)), CORNER_THICKNESS, CORNER_THICKNESS, 0, 90, $lime);
			
				// fill out the top edge
			imageline($thumb, (CORNER_THICKNESS/2), 0, ($thumb_x-(CORNER_THICKNESS/2)), 0, $lime);
			
				// fill out the bottom edge
			imageline($thumb, CORNER_THICKNESS/2, ($thumb_y-1), ($thumb_x-(CORNER_THICKNESS/2)), ($thumb_y-1), $lime);
			
				// fill out the left edge
			imageline($thumb, 0, CORNER_THICKNESS/2, 0, ($thumb_y-(CORNER_THICKNESS/2)), $lime);
			
				// fill out the right edge
			imageline($thumb, ($thumb_x-1), CORNER_THICKNESS/2, ($thumb_x-1), ($thumb_y-(CORNER_THICKNESS/2)), $lime);
			
				// fill black bg
			imagefilltoborder($thumb, 0, 0, $lime, $black);
			imagefilltoborder($thumb, 0, $thumb_y, $lime, $black);
			imagefilltoborder($thumb, $thumb_x, 0, $lime, $black);
			imagefilltoborder($thumb, $thumb_x, $thumb_y, $lime, $black);
			
				
				
				// calculate the uri of the 2 images
			$orig_uri = $base_uri;
			$thumb_uri = $base_uritb;
			
				// Write 2 images to disk
			if(is_file($orig_uri)) {
				$show = "error";
				$error = "File already exists!";
				}
			else {		
				// write the records to database
			$datetime = date("Y-m-d G:i:s");
			$title = $_REQUEST['title'];
			$comment = $_REQUEST['comment'];
			Connect_to_db("Vars.inc.php");
			$sql = "INSERT INTO $table SET " .
					"name='$name', ".
					"image='$orig_uri', ". 
					"tbimage='$thumb_uri', " .
					"title='$title', " .
					"date='$datetime', " .
					"comment='$comment'";
			
			
			if (mysql_query($sql)) {
			 $show = "result"; }
			 else { echo "Couldn't execute query! " .  mysql_error();
			 		die(); } 
			
			imagejpeg($orig, $base_fs, 90);
			imagejpeg($thumb, $base_fstb, 75);
			
			
			}
			}
					
	}
			
  
 ?> </p>
	<?php 
	if(isset($show)) {
		if($show == "error") { ?>
	<h2 align="center"><font color="red"><?=$error?></font></h2> <?php }
	elseif($show == "result") { ?>
	<h2 align="center">Thumb Image</h2>
	<p align="center"><img src="<?=$thumb_uri?>"/></p>
	<?php }} ?>
	   <form enctype="multipart/form-data" method="POST" action="<?php echo $_SERVER['PHP_SELF'] ?>">
  <div align="center">
    <table width="320" border="0" align="center" cellpadding="2" cellspacing="0">
      <tr>
        <td width="91">Image:</td>
        <td width="221">
		<input name="name" type="hidden" value="<?php echo $name ?>">
        <input name="file" type="file" size="30">    </td>
      </tr>
      <tr>
        <td>Title:</td>
        <td><input name="title" type="text" id="title" size="32"></td>
      </tr>
      <tr>
        <td valign="top">Comment:</td>
        <td><textarea name="comment" cols="32" rows="4" id="comment"></textarea></td>
      </tr>
      <tr>
        <td colspan="2"><div align="right">
          <input type="submit" name="submit" value="Upload">
        </div></td>
      </tr>
</table>

</form>
<center>
<?php
foreach($menulogin as $key => $value)
	{ if ($key == 'logout') {
		echo $value;
		}
	  else { echo $value . " | " ;}
	 } ?>
</center>
<p align="center"><?php echo $page['bottom']; ?></p>
Whenever I change this code:

Code: Select all

// set colors for background and rounded corners
			$black = imagecolorallocate($thumb, 0, 0, 0);
			$lime = imagecolorallocate($thumb, 62, 0, 91);
to

Code: Select all

// set colors for background and rounded corners
			$black = imagecolorallocate($thumb, 23, 0, 34);
			$lime = imagecolorallocate($thumb, 62, 0, 91);
Then the script will NOT work at all! :( I didn't get any errors, just that it won't work at all. I don't even get my image to upload.. nor that the data being entered in my database at all. I absolutely have no idea what's wrong with it. I'm hoping that you would help me out. Thanks. :D
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

from what I remember, you have to fill the background when creating a true color image:

viewtopic.php?t=37661
User avatar
onion2k
Jedi Mod
Posts: 5263
Joined: Tue Dec 21, 2004 5:03 pm
Location: usrlab.com

Post by onion2k »

Pfft .. if people actually read my posts they'd know that clipping the corners of an image is easy..

viewtopic.php?t=36358
Dm7
Forum Commoner
Posts: 67
Joined: Sat Oct 08, 2005 9:16 pm
Location: USA

Post by Dm7 »

onion2k wrote:Pfft .. if people actually read my posts they'd know that clipping the corners of an image is easy..

viewtopic.php?t=36358
Mmm... I think my method is easier to understand. I don't know why you're using all of those weird binary 64 data. Unless you have a tutorial somewhere out there that explains how it works. No offenses. :) Plus I want to code everything by hand so I can use it as my portfolio.

Everybody:
I still get an error.. the code I have changed was:

Code: Select all

// set colors for background and rounded corners
			$bg = imagecolorallocate($thumb, 23, 0, 34);
			$lime = imagecolorallocate($thumb, 62, 0, 91);
			imagefill($thumb, 0, 0, $bg);
The original code was:

Code: Select all

// set colors for background and rounded corners
			$bg = imagecolorallocate($thumb, 0, 0, 0);
			$lime = imagecolorallocate($thumb, 62, 0, 91);
The $bg was formerly $black, but I replaced it to $bg. I am sure it isn't the case. The error is the same like I have mentioned earlier when I change 0, 0, 0 to other color like 23, 0, 34.. then it just refuse to work. The full code is mainly the same.. just replace $black with $bg. Any idea? :/
User avatar
onion2k
Jedi Mod
Posts: 5263
Joined: Tue Dec 21, 2004 5:03 pm
Location: usrlab.com

Post by onion2k »

Dm7 wrote:Mmm... I think my method is easier to understand. I don't know why you're using all of those weird binary 64 data.
The "weird" binary 64 data are a couple of PNG files. Encoding them like that means I don't have to say "download these files.." for the code to work. What it does is open a 'corner' PNG file, change the colour of it, make 4 copies (each rotated 90 degrees), and then use imagecopyresampled() to draw the corners on to the original image.

Fair play to you if you want to write your own though.
Dm7
Forum Commoner
Posts: 67
Joined: Sat Oct 08, 2005 9:16 pm
Location: USA

Post by Dm7 »

onion2k wrote:
Dm7 wrote:Mmm... I think my method is easier to understand. I don't know why you're using all of those weird binary 64 data.
The "weird" binary 64 data are a couple of PNG files. Encoding them like that means I don't have to say "download these files.." for the code to work. What it does is open a 'corner' PNG file, change the colour of it, make 4 copies (each rotated 90 degrees), and then use imagecopyresampled() to draw the corners on to the original image.

Fair play to you if you want to write your own though.
Ah *nods*
But how do you know what data to put in it.. especially the one you have with $c variable. o_0 I have no idea what that's for. lol
Edited: I looked over at $c variable and understood it a bit better. So you used $c variable that had an image of rounded corner encoded in 64 so therefore it already exists as a string (so you dont have to download the image itself)... but I am afraid I don't understand the alpha part though. Care to explain? :)

(For everybody, I still have that silly hidden error for the filltotheborder function whenever I change bg color from 0,0,0 to something else... any idea anybody?)
Dm7
Forum Commoner
Posts: 67
Joined: Sat Oct 08, 2005 9:16 pm
Location: USA

Post by Dm7 »

I have researched everywhere and tried to figure out why it's not working... so far.. I'm having no luck. I only can make those thumbnail images with those rounded corners when it has black background (0, 0, 0), but not when I use anything else than 0, 0, 0. When I use other color, the picture wouldn't be even calucated at all and doesn't return the result at all.
Dm7
Forum Commoner
Posts: 67
Joined: Sat Oct 08, 2005 9:16 pm
Location: USA

Post by Dm7 »

Code: Select all

// generates thumbnail image - $orig is for imagecreate function
function makeThumb($orig) {
			if ($orig) {
			// fetch the size of the original and overlay images,
			// and calculate the size of the new image and thumb.
				
		$width = imagesx($orig);
		$height = imagesy($orig);
		
									
			// Calculate thumbnail size to avoid distortions
			
		$imageratio_x = $width / MAX_WIDTH;
		$imageratio_y = $height / MAX_HEIGHT;
			
				if ($imageratio_x > $imageratio_y) {
					$thumb_x = MAX_WIDTH;
					$thumb_y = round($height / $imageratio_x);
				}
				elseif ($imageradio_x < $imageratio_y) {
					$thumb_x = round($width / $imageratio_y);
					$thumb_y = MAX_HEIGHT;
				}
				elseif ($imageradio_x == $imageratio_y) {
					$thumb_x = MAX_WIDTH;
					$thumb_y = MAX_HEIGHT;
				}
				else {
					$show = 'error';
					$error = 'error in calucating the thumbnail size!';
				}
			
				// create the thumb image, and scale the original in it.
			$thumb = imagecreatetruecolor($thumb_x, $thumb_y);
			imagecopyresampled($thumb, $orig, 0, 0, 0, 0, $thumb_x, $thumb_y, $width, $height);	
			return $thumb;
			} else {
			echo "Couldn't generate thumbnail image! Not valid!";
			}
}
?>

Code: Select all

<?php
include('functions_main.inc.php');
include('configuration.inc.php');

$im = imagecreatefromjpeg("webdesignconcept_31.jpg");
makeThumb($im);
header("Content-type:image/jpeg"); 
imagejpeg($im);
imagedestroy($im);

?>
It didn't shrink to 150 x 150 size. I didn' get any error and the image is shown, but it hasn't been resized. ??? *scratches her head*
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

you're returning $thumb, but not using/capturing it in your makeThumb() call..
Dm7
Forum Commoner
Posts: 67
Joined: Sat Oct 08, 2005 9:16 pm
Location: USA

Post by Dm7 »

feyd wrote:you're returning $thumb, but not using/capturing it in your makeThumb() call..
Still no clue.....
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

Code: Select all

makeThumb($im);
Your only calling the function, but not using/storing the return...
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

your function, makeThumb() returns $thumb when the image was created. You never use the returned information from the function in your later code snippet.
Post Reply