First Commit
This commit is contained in:
1 parent
5eb9dd037d
commit
2e62c0e60b
11877 files changed
+2035312
No files matched your search
+51
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
$maxThumbDimension = 50;
|
||||
|
||||
$dir = $argv[1];
|
||||
$imagedir = "files/$dir/product_images";
|
||||
echo("$imagedir\n");
|
||||
|
||||
$files = array();
|
||||
if (is_dir($imagedir)) {
|
||||
$dir = opendir($imagedir);
|
||||
while (($file = readdir($dir)) != false) {
|
||||
if ($file == ".") continue;
|
||||
if ($file == "..") continue;
|
||||
if (preg_match("/-tn\./",$file)) continue;
|
||||
$files[] = $file;
|
||||
}
|
||||
}
|
||||
|
||||
$cmd="/usr/bin/convert";
|
||||
|
||||
for ($i = 0; $i < count($files); $i++) {
|
||||
$image = $files[$i];
|
||||
|
||||
list($name,$ext) = explode('.',$image);
|
||||
$thumbnail = $name."-tn.".$ext;
|
||||
echo("$thumbnail\n");
|
||||
|
||||
// Get image dimensions
|
||||
$image_size = GetImageSize("$imagedir/$image");
|
||||
$image_width = $image_size[0];
|
||||
$image_height = $image_size[1];
|
||||
|
||||
$target = "$imagedir/temp";
|
||||
|
||||
if ($image_width >= $image_height) {
|
||||
// Create the thumbnail
|
||||
$height = intval($image_height * $maxThumbDimension / $image_width);
|
||||
$command = "$cmd -size {$image_width}x$image_height $imagedir/$image -resize {$maxThumbDimension}x$height +profile \"*\" $target";
|
||||
exec($command);
|
||||
rename($target,"$imagedir/$thumbnail");
|
||||
}
|
||||
else {
|
||||
// Create the thumbnail
|
||||
$width = intval($image_width * $maxThumbDimension / $image_height);
|
||||
$command = "$cmd -size {$image_width}x{$image_height} $imagedir/$image -resize {$width}x{$maxThumbDimension} +profile \"*\" $target";
|
||||
exec($command);
|
||||
rename($target,"$imagedir/$thumbnail");
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
Reference in new issue
Block a user