Skip to content

Thumbnail SVGs with long preambles - #2527

Merged
tf merged 1 commit into
codevise:masterfrom
tf:svg-thumbnails
Nov 13, 2026
Merged

tf merged 1 commit into
codevise:masterfrom
tf:svg-thumbnails

Conversation

@tf

@tf tf commented Nov 13, 2026

Copy link
Copy Markdown
Member

libvips only detects SVGs whose svg tag appears within the first kilobyte of the file. Editors like Adobe Illustrator write XML declarations, comments and doctype entity blocks that push the tag further down. Processing such files failed with "is not a known file format" and left the image unusable.

Fall back to svgload for files with SVG extension that libvips cannot detect. Files of other formats with an SVG extension keep going through format detection. Since svgload does not shrink on load like thumbnail does, pass a scale derived from the target geometry to keep SVGs with huge declared dimensions from being rendered at full size.

libvips only detects SVGs whose svg tag appears within the first
kilobyte of the file. Editors like Adobe Illustrator write XML
declarations, comments and doctype entity blocks that push the tag
further down. Processing such files failed with "is not a known file
format" and left the image unusable.

Fall back to svgload for files with SVG extension that libvips cannot
detect. Files of other formats with an SVG extension keep going
through format detection. Since svgload does not shrink on load like
thumbnail does, pass a scale derived from the target geometry to keep
SVGs with huge declared dimensions from being rendered at full size.
@tf tf added this to the v17.3 milestone Nov 13, 2026
@tf
tf merged commit 5b88600 into codevise:master Nov 13, 2026
16 checks passed
@tf
tf deleted the svg-thumbnails branch November 18, 2026 13:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant