| 
	
 | 
 Posted by Mike on 08/23/06 09:18 
I'm resizing images so no matter what size (dims not file size) people 
up load, the image will always fit on the screen where I want it to. 
 
I tried the following script (from PHP.net) and it works great... 
 
<?php 
// File and new size 
$filename = "12.jpg"; 
// Set a maximum height and width 
$width = 200; 
$height = 200; 
 
// Content type 
header('Content-type: image/jpeg'); 
 
// Get new dimensions 
list($width_orig, $height_orig) = getimagesize($filename); 
 
$ratio_orig = $width_orig/$height_orig; 
 
if ($width/$height > $ratio_orig) { 
   $width = $height*$ratio_orig; 
} else { 
   $height = $width/$ratio_orig; 
} 
 
// Resample 
$image_p = imagecreatetruecolor($width, $height); 
$image = imagecreatefromjpeg($filename); 
imagecopyresampled($image_p, $image, 0, 0, 0, 0, $width, $height, 
$width_orig, $height_orig); 
 
// Output 
imagejpeg($image_p, null, 100); 
?> 
 
What I need to do is display the output image in say a cell in a table 
but I can't get it to work. 
 
For example... 
 
<html> 
<head> 
<title>Untitled Document</title> 
<meta http-equiv="Content-Type" content="text/html; 
charset=iso-8859-1"> 
</head> 
 
<body> 
<table width="120" border="0" cellspacing="0"> 
  <tr> 
    <td><?php imagejpeg($image_p, null, 100);?> </td> 
    <td> </td> 
  </tr> 
  <tr> 
    <td> </td> 
    <td> </td> 
  </tr> 
</table> 
</body> 
</html> 
 
But this just outputs what looks like the text version of the image. 
 
Anyone got any idea?? 
 
Many Thanks 
 
Mike
 
[Back to original message] 
 |