We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Banding facility of UploadBehavior::_resize() doesn't work correctly.
For example we have a source image (width: 400px; height: 300px) and going to fit it into [480x270] with UploadPack.
In the banding login in _resize() is following:
if ($srcW > $srcH) $ratio = $destW/$srcW; else $ratio = $destH/$srcH; $resizeW = $srcW*$ratio; $resizeH = $srcH*$ratio;
$srcW = 400, $srcH = 300, $destW = 480, $destH = 270. $srcW (400) > $srcH (300) so $ratio = 480 / 400 = 1.2, $resizeW = 400 * 1.2 = 480, $resizeH = 300 * 1.2 = 360.
However, $resizeH (360) > $destH (270) so destination image will be cropped in top side and bottom side, not banding with while rectangle.
This can be fixed by following code:
$srcRatio = $srcW / $srcH; // >1: landscape; =1: square; <1: portrait $destRatio = $destW / $destH; if ( $srcRatio > $destRatio ) { // source is "flatter" than destination => fit in width $resizeW = $destW; $resizeH = $resizeW / $srcRatio; } else { // source is "taller" than destination => fit in height $resizeH = $destH; $resizeW = $resizeH * $srcRatio; }
Hope this helps.
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Banding facility of UploadBehavior::_resize() doesn't work correctly.
For example we have a source image (width: 400px; height: 300px) and going to fit it into [480x270] with UploadPack.
In the banding login in _resize() is following:
$srcW = 400, $srcH = 300, $destW = 480, $destH = 270. $srcW (400) > $srcH (300) so $ratio = 480 / 400 = 1.2, $resizeW = 400 * 1.2 = 480, $resizeH = 300 * 1.2 = 360.
However, $resizeH (360) > $destH (270) so destination image will be cropped in top side and bottom side, not banding with while rectangle.
This can be fixed by following code:
Hope this helps.
The text was updated successfully, but these errors were encountered: