summaryrefslogtreecommitdiff
path: root/core/helpers
diff options
context:
space:
mode:
authorBharat Mediratta <bharat@menalto.com>2009-03-09 06:59:05 +0000
committerBharat Mediratta <bharat@menalto.com>2009-03-09 06:59:05 +0000
commit4fed34873a7a4fddb846d4912dabe88cb3cae2f0 (patch)
treec820eabab3a84e9910a1c2ddfabbcfad42cfa222 /core/helpers
parentb8cf195be8ca684734609cf19e8bf3eec9659cff (diff)
Don't let graphics::resize() upscale images.
Fixes ticket #117.
Diffstat (limited to 'core/helpers')
-rw-r--r--core/helpers/graphics.php12
1 files changed, 9 insertions, 3 deletions
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);
+ }
}
/**