Skip to content

Commit

Permalink
avoid unexpected division by zero in image transform (#2333)
Browse files Browse the repository at this point in the history
* avoid unexpected division by zero in image transform

* ensure stringified viewport when setting \epfsbox options
  • Loading branch information
dginev authored Apr 1, 2024
1 parent de34fac commit 38e663d
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/LaTeXML/Package/epsf.sty.ltxml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ DefConstructor('\epsfbox[] Semiverbatim',
properties => sub {
my ($document, $bb, $graphic) = @_;
my $clip = LookupValue('epsf_clip');
my $options = ($clip ? ($bb ? "viewport=$bb, clip" : "clip") : '');
my $options = ($clip ? ($bb ? "viewport=" . ToString($bb) . ", clip" : "clip") : '');
my ($file, @candidates) = image_candidates(ToString($graphic));
my $w = LookupRegister('\epsfxsize');
my $h = LookupRegister('\epsfysize');
Expand Down
1 change: 1 addition & 0 deletions lib/LaTeXML/Util/Image.pm
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,7 @@ sub image_graphicx_size {
elsif ($op eq 'scale-to') {
# $a1 => width (pts), $a2 => height (pts), $a3 => preserve aspect ratio.
if ($a3) { # If keeping aspect ratio, ignore the most extreme request
return unless $w && $h;
if ($a1 / $w < $a2 / $h) { $a2 = $h * $a1 / $w; }
else { $a1 = $w * $a2 / $h; } }
($w, $h) = (ceil($a1 * $dppt), ceil($a2 * $dppt)); }
Expand Down

0 comments on commit 38e663d

Please sign in to comment.