Author Topic: php pros, help me with thumbnail display  (Read 206 times)

0 Members and 1 Guest are viewing this topic.

Offline prakash911Topic starter

  • Irregular
  • Posts: 20
    • View Profile
php pros, help me with thumbnail display
« on: March 17, 2010, 07:13:41 PM »
here is my code to generate and display thumbnail

function createthumbnail($name,$filename,$width,$height)
{
  
$system explode('.',$name);

  if (
preg_match('/jpg|jpeg/',$system[1]))
  {
	
$image imagecreatefromjpeg($name);
  }
  if (
preg_match('/png/',$system[1]))
  {
	
$image imagecreatefrompng($name);
  }
	
	

  
$x imageSX($image);
  
$y imageSY($image);

  if (
$x $y
  {
	
$thumb_w$width;
	
$thumb_h$y*($height/$x);
  }

  if (
$x $y
  {
	
$thumb_w$x*($width/$y);
	
$thumb_h$height;
  }

  if (
$x == $y
  {
	
$thumb_w $width;
	
$thumb_h $height;
  }

  
$dst_img ImageCreateTrueColor($thumb_w,$thumb_h);
  
imagecopyresampled($dst_img,$image,0,0,0,0,$thumb_w,$thumb_h,$x,$y);

  if (
preg_match("/png/",$system[1]))
  {
	
imagepng($dst_img,$filename); 
  } else {
	
imagejpeg($dst_img,$filename); 
  }

  
imagedestroy($dst_img); 
  
imagedestroy($image); 
}


while ($row mysql_fetch_assoc($result))
   {
      print 
"<tr>\n";
      foreach (
$row as $col_value)
      {
         print 
"<tb>";
         
createthumbnail('pics/beautifulWebDesign.jpg','pics/beautifulWebDesign.jpg',100,100);
         print 
"</tb>\n";
         
$col_value htmlspecialchars(stripslashes($col_value));
         print 
"<td>$col_value</td>\n";
      }

      
$isbn $row['isbn'];
?>
	
  
      <form action="<?php echo $self?>" method="POST">
      <td>
      <input type="hidden" name="isbn" value="<?php echo $isbn?>">
      <input type="text" name="quantity" value="1" size="2">
      <input type="submit" name="add" value="add">
      </td>
      </form>
<?php
   
}
?>


i want the image to be displayed in the pictures column down all the rows, but when i run it i get this. no image is being displayed and i am not even getting any error messages.

« Last Edit: March 17, 2010, 07:14:20 PM by prakash911 »

Offline prakash911Topic starter

  • Irregular
  • Posts: 20
    • View Profile
Re: php pros, help me with thumbnail display
« Reply #1 on: March 17, 2010, 08:24:53 PM »
please i really need this to work, cant anyone spot the problem.