@@ -174,8 +174,8 @@ sizeInPoints s = (pxXf * 72 / dpiXf, pxYf * 72 / dpiYf)
174174-- | Calculate (height, width) in points, considering the desired dimensions in the
175175-- attribute, while falling back on the image file's dpi metadata if no dimensions
176176-- are specified in the attribute (or only dimensions in percentages).
177- desiredSizeInPoints :: WriterOptions -> Attr -> ImageSize -> (Double , Double )
178- desiredSizeInPoints opts attr s =
177+ desiredSizeInPoints :: WriterOptions -> Attr -> Maybe Integer -> ImageSize -> (Double , Double )
178+ desiredSizeInPoints opts attr pageWidthPoints' s =
179179 case (getDim Width , getDim Height ) of
180180 (Just w, Just h) -> (w, h)
181181 (Just w, Nothing ) -> (w, w / ratio)
@@ -184,7 +184,11 @@ desiredSizeInPoints opts attr s =
184184 where
185185 ratio = fromIntegral (pxX s) / fromIntegral (pxY s)
186186 getDim dir = case dimension dir attr of
187- Just (Percent _) -> Nothing
187+ Just (Percent a) ->
188+ case (dir, pageWidthPoints') of
189+ (Width , Just pageWidthPoints) ->
190+ Just $ fromIntegral pageWidthPoints * a
191+ _ -> Nothing
188192 Just dim -> Just $ inPoints opts dim
189193 Nothing -> Nothing
190194
0 commit comments