From 4fed34873a7a4fddb846d4912dabe88cb3cae2f0 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Mon, 9 Mar 2009 06:59:05 +0000 Subject: Don't let graphics::resize() upscale images. Fixes ticket #117. --- core/helpers/graphics.php | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'core/helpers') diff --git a/core/helpers/graphics.php b/core/helpers/graphics.php index 3d0c405d..e16b3086 100644 --- a/core/helpers/graphics.php +++ b/core/helpers/graphics.php @@ -153,9 +153,15 @@ class graphics_Core { self::init_toolkit(); } - Image::factory($input_file) - ->resize($options["width"], $options["height"], $options["master"]) - ->save($output_file); + $dims = getimagesize($input_file); + if (max($dims[0], $dims[1]) < min($options["width"], $options["height"])) { + // Image would get upscaled; do nothing + copy($input_file, $output_file); + } else { + Image::factory($input_file) + ->resize($options["width"], $options["height"], $options["master"]) + ->save($output_file); + } } /** -- cgit v1.2.3