allow toggle to 'SMBC' scaling mode. 'SMBC' mode is named thusly for Saturday Morning Breakfast Cereal cartoons which are very tall. If you scale the image to constrain both dimensions, the cartoon text is illegible. So we allow the height to float and only constrain the width. The new flag allows you to overide this mode and force both dimensions to always be evaluated and constrained to the provided limit.

This commit is contained in:
zotlabs 2017-11-21 19:47:59 -08:00
parent 98e2b2a60b
commit b4f8f4df7b

View File

@ -129,7 +129,14 @@ abstract class photo_driver {
return $this->types[$this->getType()]; return $this->types[$this->getType()];
} }
public function scaleImage($max) { /**
* @brief scale image
* int $max maximum pixel size in either dimension
* boolean $float_height - if true allow height to float to any length on tall images,
* constraining only the width
*/
public function scaleImage($max, $float_height = true) {
if(!$this->is_valid()) if(!$this->is_valid())
return FALSE; return FALSE;
@ -146,7 +153,7 @@ abstract class photo_driver {
// very tall image (greater than 16:9) // very tall image (greater than 16:9)
// constrain the width - let the height float. // constrain the width - let the height float.
if((($height * 9) / 16) > $width) { if(((($height * 9) / 16) > $width) && ($float_height)) {
$dest_width = $max; $dest_width = $max;
$dest_height = intval(( $height * $max ) / $width); $dest_height = intval(( $height * $max ) / $width);
} }
@ -173,7 +180,7 @@ abstract class photo_driver {
// very tall image (greater than 16:9) // very tall image (greater than 16:9)
// but width is OK - don't do anything // but width is OK - don't do anything
if((($height * 9) / 16) > $width) { if(((($height * 9) / 16) > $width) && ($float_height)) {
$dest_width = $width; $dest_width = $width;
$dest_height = $height; $dest_height = $height;
} }