summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Smith <chris@jalakai.co.uk>2013-04-07 12:28:18 -0700
committerChristopher Smith <chris@jalakai.co.uk>2013-04-07 12:28:18 -0700
commitf20dba3663b5307c29d9c535843b51157b540ef1 (patch)
tree63365612806abdaab545b445b6af1c44f0e2293f
parent33f1e87c050a2dd2dc2b06de5d9050b16bd1f0c0 (diff)
parentf0b65004f2ff928562c2ffdfa31b4d1e4cff3ab7 (diff)
downloadrpg-f20dba3663b5307c29d9c535843b51157b540ef1.tar.gz
rpg-f20dba3663b5307c29d9c535843b51157b540ef1.tar.bz2
Merge pull request #201 from splitbrain/fetchissues
process a crop as a resize when possible
-rw-r--r--inc/media.php10
1 files changed, 10 insertions, 0 deletions
diff --git a/inc/media.php b/inc/media.php
index 2268ad877..fc4ad1d67 100644
--- a/inc/media.php
+++ b/inc/media.php
@@ -1795,6 +1795,9 @@ function media_resize_image($file, $ext, $w, $h=0){
// we wont scale up to infinity
if($w > 2000 || $h > 2000) return $file;
+ // resize necessary? - (w,h) = native dimensions
+ if(($w == $info[0]) && ($h == $info[1])) return $file;
+
//cache
$local = getCacheName($file,'.media.'.$w.'x'.$h.'.'.$ext);
$mtime = @filemtime($local); // 0 if not exists
@@ -1828,6 +1831,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];