summaryrefslogtreecommitdiff
path: root/includes
diff options
context:
space:
mode:
authorwebchick <webchick@24967.no-reply.drupal.org>2011-10-17 10:28:23 -0700
committerwebchick <webchick@24967.no-reply.drupal.org>2011-10-17 10:28:23 -0700
commit72ef1daad0b4a05014705edb36790f3c5e9bacf6 (patch)
treecaa20f3924350feaa845532d1b2cea290642b695 /includes
parent89ad342620ab99728f64de4a32e4edf6ade55aa0 (diff)
downloadbrdo-72ef1daad0b4a05014705edb36790f3c5e9bacf6.tar.gz
brdo-72ef1daad0b4a05014705edb36790f3c5e9bacf6.tar.bz2
Reverting accidental commit with last patch.
Diffstat (limited to 'includes')
-rw-r--r--includes/image.inc77
1 files changed, 20 insertions, 57 deletions
diff --git a/includes/image.inc b/includes/image.inc
index 8dc36b995..b04943b5e 100644
--- a/includes/image.inc
+++ b/includes/image.inc
@@ -160,7 +160,7 @@ function image_get_info($filepath, $toolkit = FALSE) {
* The target height, in pixels.
*
* @return
- * TRUE on success, FALSE on failure.
+ * TRUE or FALSE, based on success.
*
* @see image_load()
* @see image_resize()
@@ -178,13 +178,12 @@ function image_scale_and_crop(stdClass $image, $width, $height) {
}
/**
- * Scales image dimensions while maintaining aspect ratio.
+ * Scales an image to the given width and height while maintaining aspect ratio.
*
- * The resulting dimensions can be smaller for one or both target dimensions.
+ * The resulting image can be smaller for one or both target dimensions.
*
- * @param $dimensions
- * Dimensions to be modified - an array with components width and height, in
- * pixels.
+ * @param $image
+ * An image object returned by image_load().
* @param $width
* The target width, in pixels. This value is omitted then the scaling will
* based only on the height value.
@@ -196,12 +195,13 @@ function image_scale_and_crop(stdClass $image, $width, $height) {
* up. This generally results in a low quality image.
*
* @return
- * TRUE if $dimensions was modified, FALSE otherwise.
+ * TRUE or FALSE, based on success.
*
- * @see image_scale()
+ * @see image_load()
+ * @see image_scale_and_crop()
*/
-function image_dimensions_scale(array &$dimensions, $width = NULL, $height = NULL, $upscale = FALSE) {
- $aspect = $dimensions['height'] / $dimensions['width'];
+function image_scale(stdClass $image, $width = NULL, $height = NULL, $upscale = FALSE) {
+ $aspect = $image->info['height'] / $image->info['width'];
if ($upscale) {
// Set width/height according to aspect ratio if either is empty.
@@ -214,56 +214,19 @@ function image_dimensions_scale(array &$dimensions, $width = NULL, $height = NUL
$height = !empty($height) ? $height : 9999999;
// Don't scale up.
- if (round($width) >= $dimensions['width'] && round($height) >= $dimensions['height']) {
- return FALSE;
+ if (round($width) >= $image->info['width'] && round($height) >= $image->info['height']) {
+ return TRUE;
}
}
if ($aspect < $height / $width) {
- $dimensions['width'] = $width;
- $dimensions['height'] = (int) round($width * $aspect);
+ $height = $width * $aspect;
}
else {
- $dimensions['width'] = (int) round($height / $aspect);
- $dimensions['height'] = $height;
- }
-
- return TRUE;
-}
-
-/**
- * Scales an image while maintaining aspect ratio.
- *
- * The resulting image can be smaller for one or both target dimensions.
- *
- * @param $image
- * An image object returned by image_load().
- * @param $width
- * The target width, in pixels. This value is omitted then the scaling will
- * based only on the height value.
- * @param $height
- * The target height, in pixels. This value is omitted then the scaling will
- * based only on the width value.
- * @param $upscale
- * Boolean indicating that files smaller than the dimensions will be scaled
- * up. This generally results in a low quality image.
- *
- * @return
- * TRUE on success, FALSE on failure.
- *
- * @see image_dimensions_scale()
- * @see image_load()
- * @see image_scale_and_crop()
- */
-function image_scale(stdClass $image, $width = NULL, $height = NULL, $upscale = FALSE) {
- $dimensions = $image->info;
-
- // Scale the dimensions - if they don't change then just return success.
- if (!image_dimensions_scale($dimensions, $width, $height, $upscale)) {
- return TRUE;
+ $width = $height / $aspect;
}
- return image_resize($image, $dimensions['width'], $dimensions['height']);
+ return image_resize($image, $width, $height);
}
/**
@@ -277,7 +240,7 @@ function image_scale(stdClass $image, $width = NULL, $height = NULL, $upscale =
* The target height, in pixels.
*
* @return
- * TRUE on success, FALSE on failure.
+ * TRUE or FALSE, based on success.
*
* @see image_load()
* @see image_gd_resize()
@@ -304,7 +267,7 @@ function image_resize(stdClass $image, $width, $height) {
* be white.
*
* @return
- * TRUE on success, FALSE on failure.
+ * TRUE or FALSE, based on success.
*
* @see image_load()
* @see image_gd_rotate()
@@ -328,7 +291,7 @@ function image_rotate(stdClass $image, $degrees, $background = NULL) {
* The target height, in pixels.
*
* @return
- * TRUE on success, FALSE on failure.
+ * TRUE or FALSE, based on success.
*
* @see image_load()
* @see image_scale_and_crop()
@@ -352,7 +315,7 @@ function image_crop(stdClass $image, $x, $y, $width, $height) {
* An image object returned by image_load().
*
* @return
- * TRUE on success, FALSE on failure.
+ * TRUE or FALSE, based on success.
*
* @see image_load()
* @see image_gd_desaturate()
@@ -416,7 +379,7 @@ function image_load($file, $toolkit = FALSE) {
* original image file will be overwritten.
*
* @return
- * TRUE on success, FALSE on failure.
+ * TRUE or FALSE, based on success.
*
* @see image_load()
* @see image_gd_save()