ImageSize: take bounding box origin into account for EPS.

The %%BoundingBox comment gives llx lly urx ury; the size was
computed from the upper corner alone, giving wrong dimensions for
EPS files whose bounding box has a non-zero origin. Also decode the
coordinates leniently, so that invalid UTF-8 on the line cannot
raise an exception from pure code.

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
John MacFarlane
2026-09-07 04:45:36 +00:00
co-authored by Claude
parent ddb70d1d13
commit 60edf31eaa
+7 -5
View File
@@ -292,12 +292,14 @@ epsSize img = do
case ls' of
[] -> mzero
(x:_) -> case B.words x of
[_, _, _, ux, uy] -> do
ux' <- safeRead $ TE.decodeUtf8 ux
uy' <- safeRead $ TE.decodeUtf8 uy
[_, llx, lly, urx, ury] -> do
llx' <- safeRead $ TE.decodeUtf8Lenient llx
lly' <- safeRead $ TE.decodeUtf8Lenient lly
urx' <- safeRead $ TE.decodeUtf8Lenient urx
ury' <- safeRead $ TE.decodeUtf8Lenient ury
return ImageSize{
pxX = ux'
, pxY = uy'
pxX = urx' - llx'
, pxY = ury' - lly'
, dpiX = 72
, dpiY = 72 }
_ -> mzero