Update of /cvsroot/php-blog/serendipity
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32487
Modified Files:
Tag: branch-smarty
serendipity_functions_images.inc.php
Log Message:
fix image calculations, see mailinglist
Index: serendipity_functions_images.inc.php
===================================================================
RCS file: /cvsroot/php-blog/serendipity/serendipity_functions_images.inc.php,v
retrieving revision 1.36.2.2
retrieving revision 1.36.2.3
diff -u -d -r1.36.2.2 -r1.36.2.3
--- serendipity_functions_images.inc.php 28 Oct 2004 20:35:30 -0000 1.36.2.2
+++ serendipity_functions_images.inc.php 29 Oct 2004 10:11:08 -0000 1.36.2.3
@@ -635,17 +635,21 @@
$div_width = $width / $newwidth;
$div_height = $height / $newwidth;
- if ($div_width <= 1) {
- // do not scale small images
+ if ($div_width <= 1 && $div_height <= 1) {
+ // do not scale small images where both sides are smaller than the thumbnail dimensions
$newheight = $height;
$newwidth = $width;
} elseif ($div_width >= $div_height) {
// max width - calculate height, keep width as scaling base
$newheight = round($height / $div_width);
+ // make sure the height is at least 1 pixel for extreme images
+ $newheight = ($newheight >= 1 ? $newheight : 1);
} else {
// max height - calculate width, keep height as scaling base
$newheight = $newwidth;
$newwidth = round($width / $div_height);
+ // make sure the width is at least 1 pixel for extreme images
+ $newwidth = ($newwidth >= 1 ? $newwidth : 1);
}
}
|