diff options
author | zotlabs <mike@macgirvin.com> | 2017-11-22 15:43:48 -0800 |
---|---|---|
committer | zotlabs <mike@macgirvin.com> | 2017-11-22 15:43:48 -0800 |
commit | 9936670f44b53e391d997fd024faa329b8a0c803 (patch) | |
tree | a88c45c92843703049a91cf7b4ab4e374b52de97 /include | |
parent | 6ac3fc4e0724a881ed3b26fa8d0912f38512d2ca (diff) | |
parent | b4f8f4df7bc5cc8a74240506cd536224cb31e114 (diff) | |
download | volse-hubzilla-9936670f44b53e391d997fd024faa329b8a0c803.tar.gz volse-hubzilla-9936670f44b53e391d997fd024faa329b8a0c803.tar.bz2 volse-hubzilla-9936670f44b53e391d997fd024faa329b8a0c803.zip |
Merge branch 'dev' of https://github.com/redmatrix/hubzilla into dev_merge
Diffstat (limited to 'include')
-rw-r--r-- | include/attach.php | 7 | ||||
-rw-r--r-- | include/photo/photo_driver.php | 13 |
2 files changed, 14 insertions, 6 deletions
diff --git a/include/attach.php b/include/attach.php index 0f31ed012..7988286c9 100644 --- a/include/attach.php +++ b/include/attach.php @@ -1632,16 +1632,17 @@ function find_filename_by_hash($channel_id, $attachHash) { } /** - * @brief Pipes $in to $out in 16MB chunks. + * @brief Pipes $in to $out in 16KB chunks. * * @param resource $in File pointer of input * @param resource $out File pointer of output + * @param int $bufsize size of chunk, default 16384 * @return number with the size */ -function pipe_streams($in, $out) { +function pipe_streams($in, $out, $bufize = 16384) { $size = 0; while (!feof($in)) - $size += fwrite($out, fread($in, 16384)); + $size += fwrite($out, fread($in, $bufsize)); return $size; } diff --git a/include/photo/photo_driver.php b/include/photo/photo_driver.php index f75ff2386..6af753195 100644 --- a/include/photo/photo_driver.php +++ b/include/photo/photo_driver.php @@ -129,7 +129,14 @@ abstract class photo_driver { 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()) return FALSE; @@ -146,7 +153,7 @@ abstract class photo_driver { // very tall image (greater than 16:9) // constrain the width - let the height float. - if((($height * 9) / 16) > $width) { + if(((($height * 9) / 16) > $width) && ($float_height)) { $dest_width = $max; $dest_height = intval(( $height * $max ) / $width); } @@ -173,7 +180,7 @@ abstract class photo_driver { // very tall image (greater than 16:9) // but width is OK - don't do anything - if((($height * 9) / 16) > $width) { + if(((($height * 9) / 16) > $width) && ($float_height)) { $dest_width = $width; $dest_height = $height; } |