Skip to content

Commit

Permalink
CHange svg creation logic
Browse files Browse the repository at this point in the history
  • Loading branch information
tmathern committed Mar 15, 2024
1 parent 21156a4 commit 507088f
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions lib/postprocessing/image.js
Original file line number Diff line number Diff line change
Expand Up @@ -634,10 +634,16 @@ async function imagePostProcess(intermediateRendition, rendition, directories) {

function convertSvg(img, instructions) {
// ImageMagick automatically keeps aspect ratio
// Only using width because ImageMagick will use the smallest value whether it be width or height
const width = instructions.width || SVG_DEFAULT_WIDTH;
let imageSize = SVG_DEFAULT_WIDTH;

img = handleTransparency(img, instructions);
if(instructions.width && instructions.height) {
// image magick will keep aspect ratio
imageSize = `${instructions.width}x${instructions.height}`;
} else if(instructions.width) {
imageSize = `${instructions.width}x`;
} else if(instructions.height) {
imageSize = `x${instructions.height}`;
}

// some svgs have no size (only percentage width/height), so we scale them to our target size
img.in("-size", `${width}`); // 2020-11-10 img.rawSize() will not be applied at the correct time and the SVG will be upscaled resulting in a fuzzy final rendition
Expand Down

0 comments on commit 507088f

Please sign in to comment.