Jump to content

resize an image


forumnz

Recommended Posts

My script here displays all the images in a directory with a caption underneath each one. I need to have it so that the images will be no more than 100x100 px. However, I dont want an image which is 200x300 to be reduced to 100x100 because that would look stupid. I also cant do anything like 50% because some images are already 100x100 and the rest are all different sizes.

 

Please help if possible.

 

 <?php
$d = dir("sport_motocross");
//echo "Handle: " . $d->handle . "\n";
//echo "Path: " . $d->path . "\n";
while (false !== ($entry = $d->read())) {
   if ($entry == "." || $entry == "..") {
       continue;
   }elseif (!ereg('gif|jpg|jpeg|png', $entry)) {
       continue;
   }  
   echo "<div align=center class=float>" . "<img src=" . "http://www.designervision.co.nz/magik/gallery/sport_motocross/" .$entry. "\n" . "/>" . "<br />" . "<p>" .$entry. "</p>" . "</div>";


  
  }
$d->close();
?>

Link to comment
https://forums.phpfreaks.com/topic/46031-resize-an-image/
Share on other sites

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.