what I want if the files is smaller then
$max_width = "400";
$max_height = "400";
don't resize and if lrger resize to
$max_width = "400";
$max_height = "400";
does anyone know how I would do this.
Code: Select all
<?php
// Setup the maximium width and height for the finished image code came from http://www.rubblewebs.co.uk/imagemagick/codes/auto_thumb.php
$max_width = "400";
$max_height = "400";
// Directory containing the images - need the trailing slash /
$read = 'upload/';
$read1 = 'thumbs/';
// Open the directory and create an array of the images
$myDirectory = opendir( $read );
while( $entryName = readdir( $myDirectory ))
{
// This will only select jpg images from the folder
foreach (glob($dir."{*.jpg,*.png,*.gif}",GLOB_BRACE ) as $filename) {
$dirArray[]=$entryName;
}
}
closedir( $myDirectory );
// Count the number of images
$indexCount = count($dirArray);
for ( $i=0; $i<$indexCount; $i++ )
{
$name = $read.$dirArray[$i];
// Save resized images as folder/thumb_original name
//$new_name = $read1."thumb_".$dirArray[$i];
$new_name = $read1.$dirArray[$i];
// Get the image size for use in the code
$size=GetImageSize( $name );
exec("convert -size {$size[0]}x{$size[1]} $name -thumbnail $max_widthx$max_height $new_name");
}
?>