diff options
author | Christopher Smith <chris@jalakai.co.uk> | 2013-03-19 17:31:06 +0000 |
---|---|---|
committer | Christopher Smith <chris@jalakai.co.uk> | 2013-03-19 17:31:06 +0000 |
commit | fd9d3278078df67aab6cee0c2b7b43a27f206983 (patch) | |
tree | 8dcae4a6bdfc15f9e99bcf454cfe4084213f6421 | |
parent | d02ff93090ec7ab874d4f61fbef15d5b3a2eb341 (diff) | |
download | rpg-fd9d3278078df67aab6cee0c2b7b43a27f206983.tar.gz rpg-fd9d3278078df67aab6cee0c2b7b43a27f206983.tar.bz2 |
avoid creating an intermediate crop image when the final image will match a resize
-rw-r--r-- | inc/media.php | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/inc/media.php b/inc/media.php index 2268ad877..654d31cb4 100644 --- a/inc/media.php +++ b/inc/media.php @@ -1828,6 +1828,13 @@ function media_crop_image($file, $ext, $w, $h=0){ // calculate crop size $fr = $info[0]/$info[1]; $tr = $w/$h; + + // check if the crop can be handled completely by resize, + // i.e. the specified width & height match the aspect ratio of the source image + if ($w == round($h*$fr)) { + return media_resize_image($file, $ext, $w); + } + if($tr >= 1){ if($tr > $fr){ $cw = $info[0]; |