Jump to content

Image resize not working


Recommended Posts

My code isn't giving me any errors but dosent display my image at all... not sure why

<?php 

$img_path = "file/".$rows ['file'];

$image_t = getimagesize($img_path); 

imageResize($image_t[0],  
$image_t[1], 600); ?>					
				<?php 

function imageResize($width, $height, $target) { 

if ($width > $height) { 
$percentage = ($target / $width); 
} else { 
$percentage = ($target / $height); 
} 

$width = round($width * $percentage); 
$height = round($height * $percentage); 

return "width=\"$width\" height=\"$height\""; 

} ?>

 

 

Link to comment
https://forums.phpfreaks.com/topic/104763-image-resize-not-working/
Share on other sites

Sorry here is the code with the echo... but still no luck.

<?php 

$img_path = "file/".$rows ['file'];

$image_t = getimagesize($img_path); 

imageResize($image_t[0],  
$image_t[1], 600); ?>					

<?php 

function imageResize($width, $height, $target) { 

if ($width > $height) { 
$percentage = ($target / $width); 
} else { 
$percentage = ($target / $height); 
} 

$width = round($width * $percentage); 
$height = round($height * $percentage); 

return "width=\"$width\" height=\"$height\""; 

} 

	echo $row["$image_t"];

?>

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.