Jump to content

how to resize images in php


franknu

Recommended Posts

Ok, i want to resize images in php the problem is that i want to resize the images when they display

i wonder what is the best approach

 

this is the code that  i  have to display the pictures

 


<?php
                $image = preg_replace('#^.*/public_html#', '', $row['Picture3']);
            echo '<img src="' . $image . '" width="250" height="250">'; 
			 ?>  

 

basicly, i want the pictures to be resize proporsionaly

 

help thank u

Link to comment
https://forums.phpfreaks.com/topic/49233-how-to-resize-images-in-php/
Share on other sites

Its quite simple. Just use something like this

<?php
$path = "images/image.jpg";
$size = getimagesize($path);
$height = $size[1] /5;
$width = $size[0] / 5;
?>
<img src="<?php echo $path; ?>" width="<?php echo $width; ?>" height="<?php echo $height; ?>">

 

That will proportionally reduce the size by a 80% I think.

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.