Commit 29901496 authored by Bogdan Mucenica's avatar Bogdan Mucenica 🏍

fix fit crop

parent 393249d0
......@@ -55,20 +55,23 @@
$cropX = 0;
$cropY = 0;
$w1 = $imageW;
$h1 = $w1 * $sourceH / $sourceW;
if ($sourceW < $sourceH) {
$r = $imageH / $imageW;
$cropW = $sourceW;
$cropH = $cropW * $r;
$cropY = (($sourceH - $cropH) / 2) / $r;
if ($h1 > $imageH) {
$cropH = $imageH;
$cropW = $imageH * $sourceW / $sourceH;
$cropX = ($imageW - $cropW ) / 2;
} else {
$r = $imageW / $imageH;
$cropH = $sourceH;
$cropW = $cropH * $r;
$cropX = (($sourceW - $cropW) / 2) / $r;
$cropW = $imageW;
$cropH = $imageW * $sourceH / $sourceW;
$cropY = ($imageH - $cropH ) / 2;
}
imagecopyresampled($resizedFinal, $this->image, 0, 0, $cropX, $cropY, $imageW, $imageH, $cropW, $cropH);
imagecopyresampled($resizedFinal, $this->image, $cropX, $cropY, 0, 0, $cropW, $cropH, $sourceW, $sourceH);
break;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment