From 60edf31eaaa1475bfd8e67aadd6c4c2c79bb0302 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Mon, 7 Sep 2026 04:45:36 +0000 Subject: [PATCH] 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 --- src/Text/Pandoc/ImageSize.hs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/Text/Pandoc/ImageSize.hs b/src/Text/Pandoc/ImageSize.hs index 5a634c1c2..bf29857ac 100644 --- a/src/Text/Pandoc/ImageSize.hs +++ b/src/Text/Pandoc/ImageSize.hs @@ -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