diff options
author | Evan Prodromou <evan@controlyourself.ca> | 2009-02-09 12:03:45 -0500 |
---|---|---|
committer | Evan Prodromou <evan@controlyourself.ca> | 2009-02-09 12:03:45 -0500 |
commit | 73b8de7c4c70d9d53537191ca273e131b76b81e9 (patch) | |
tree | fec956d81e619218ba10f1d5650414ee83a2628d /lib/imagefile.php | |
parent | 9e23b5c5d706f4573261d6530688a44a8b80bcf4 (diff) | |
parent | 805560677bc66a58c270551fa54b613642b3af97 (diff) |
Merge branch 'sgmurphy-clone/0.7.x' into 0.7.x
Diffstat (limited to 'lib/imagefile.php')
-rw-r--r-- | lib/imagefile.php | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/lib/imagefile.php b/lib/imagefile.php index db344db8f..ea24029a3 100644 --- a/lib/imagefile.php +++ b/lib/imagefile.php @@ -112,6 +112,23 @@ class ImageFile throw new Exception(_('Lost our file.')); return; } + + // Don't crop/scale if it isn't necessary + if ($size === $this->width + && $size === $this->height + && $x === 0 + && $y === 0 + && $w === $this->width + && $h === $this->height) { + + $outname = Avatar::filename($this->id, + image_type_to_extension($this->type), + $size, + common_timestamp()); + $outpath = Avatar::path($outname); + @copy($this->filepath, $outpath); + return $outname; + } switch ($this->type) { case IMAGETYPE_GIF: @@ -165,7 +182,7 @@ class ImageFile imagegif($image_dest, $outpath); break; case IMAGETYPE_JPEG: - imagejpeg($image_dest, $outpath); + imagejpeg($image_dest, $outpath, 100); break; case IMAGETYPE_PNG: imagepng($image_dest, $outpath); @@ -174,6 +191,9 @@ class ImageFile throw new Exception(_('Unknown file type')); return; } + + imagedestroy($image_src); + imagedestroy($image_dest); return $outname; } |