Skip to content

Commit

Permalink
images with pixel aspect ratio from width
Browse files Browse the repository at this point in the history
  • Loading branch information
rafalpospiech committed Feb 15, 2019
1 parent 7bbb63c commit 1a67192
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 deletions lib/Layout/ImageBox.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,18 +53,14 @@ public function measureWidth()
public function measureHeight(bool $afterPageDividing = false)
{
$style = $this->getStyle();
if ($style->getRules('height') === 'auto') {
$img = $style->getBackgroundImageStream();
$height = $img->getHeight();
if ($style->getRules('width') !== 'auto') {
$ratio = Math::div($img->getWidth(), $img->getHeight());
$height = Math::div($this->getDimensions()->getInnerWidth(), $ratio);
}
$height = Math::add($height, $style->getVerticalBordersWidth(), $style->getVerticalPaddingsWidth());
$this->getDimensions()->setHeight($height);
} else {
$this->applyStyleHeight();
$img = $style->getBackgroundImageStream();
$height = $img->getHeight();
if ($style->getRules('width') !== 'auto') {
$ratio = Math::div($img->getWidth(), $img->getHeight());
$height = Math::div($this->getDimensions()->getInnerWidth(), $ratio);
}
$height = Math::add($height, $style->getVerticalBordersWidth(), $style->getVerticalPaddingsWidth());
$this->getDimensions()->setHeight($height);
return $this;
}
}

0 comments on commit 1a67192

Please sign in to comment.