/ Published in: PHP
Expand |
Embed | Plain Text
'width' => 4000, 'height' => 3000, 'destination' => '/images/stores/original/' ), 'width' => 171, 'height' => 171, 'destination' => '/images/stores/medium/', 'strict' => true ), 'width' => 140, 'height' => 105, 'destination' => '/images/stores/small/' ) ); function upload_image($filename, $tmp_name, $sizes){ foreach($sizes as $name => $image){ $size = get_image_size($image['destination'],$filename); if($size['width'] > $image['width'] || $size['height'] > $image['height']){ if($size['height'] > $size['width']){ $width = $image['width']; } else{ $height = $image['height']; } image_resize($width, $height, $image['destination'], $filename); if($image['strict'] && ($width > $image['width'] || $height > $image['height'])){ image_crop_centercrop($image['destination'], $filename, $width, $height, 0, 0); } } $fuploaded[]=SITE_PATH.$image['destination'].$filename; } else { } } return $fuploaded; } if($_FILES['image']['size'] > 0) { $tmp_name = $_FILES['image']['tmp_name']; $images = upload_image($filename, $tmp_name, $sizes); } function image_crop_centercrop($folder, $pic, $width, $height, $x, $y) { $command=IMAGE_MOGRIFY ." -gravity center -crop ${width}x${height}+${x}+${y} " . SITE_PATH . $folder . $pic; //echo $command; }
You need to login to post a comment.
