diff options
author | rvelices <rv-github@modusoptimus.com> | 2008-08-20 00:35:22 +0000 |
---|---|---|
committer | rvelices <rv-github@modusoptimus.com> | 2008-08-20 00:35:22 +0000 |
commit | 5a6298548b194e0987cdccc8a11b04efa8c9fd61 (patch) | |
tree | a9cb03ff5870e6ed5a3e36d6ceead1391afa8587 /include/functions_picture.inc.php | |
parent | dcbaefafdfb955f61c9b83eb8d2e15eea2880694 (diff) |
- local.lang is loaded without fallback on default language or PHPWG_DEFAULT_LANGUAGE (needed to change the signature of load_language which became a little too big)
- move a function from functions.inc.php to functions_picture.inc.php (included only when necessary)
- removed some css (not as much as I wanted)
git-svn-id: http://piwigo.org/svn/trunk@2479 68402e56-0260-453c-a942-63ccdbb3a9ee
Diffstat (limited to 'include/functions_picture.inc.php')
-rw-r--r-- | include/functions_picture.inc.php | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/include/functions_picture.inc.php b/include/functions_picture.inc.php index 1b6403ff3..d1c430fde 100644 --- a/include/functions_picture.inc.php +++ b/include/functions_picture.inc.php @@ -327,4 +327,60 @@ function encode_slideshow_params($decode_params = array()) return $result; } +// The get_picture_size function return an array containing : +// - $picture_size[0] : final width +// - $picture_size[1] : final height +// The final dimensions are calculated thanks to the original dimensions and +// the maximum dimensions given in parameters. get_picture_size respects +// the width/height ratio +function get_picture_size( $original_width, $original_height, + $max_width, $max_height ) +{ + $width = $original_width; + $height = $original_height; + $is_original_size = true; + + if ( $max_width != "" ) + { + if ( $original_width > $max_width ) + { + $width = $max_width; + $height = floor( ( $width * $original_height ) / $original_width ); + } + } + if ( $max_height != "" ) + { + if ( $original_height > $max_height ) + { + $height = $max_height; + $width = floor( ( $height * $original_width ) / $original_height ); + $is_original_size = false; + } + } + if ( is_numeric( $max_width ) and is_numeric( $max_height ) + and $max_width != 0 and $max_height != 0 ) + { + $ratioWidth = $original_width / $max_width; + $ratioHeight = $original_height / $max_height; + if ( ( $ratioWidth > 1 ) or ( $ratioHeight > 1 ) ) + { + if ( $ratioWidth < $ratioHeight ) + { + $width = floor( $original_width / $ratioHeight ); + $height = $max_height; + } + else + { + $width = $max_width; + $height = floor( $original_height / $ratioWidth ); + } + $is_original_size = false; + } + } + $picture_size = array(); + $picture_size[0] = $width; + $picture_size[1] = $height; + return $picture_size; +} + ?> |