mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-10-30 12:47:13 -06:00
Raster export: refuse sizes the renderer can't produce instead of crashing
PNG/JPEG/WebP export renders the artboard at the requested scale with no size check. The CPU rasteriser addresses at most 65535 pixels a side (and panics at that edge), so a large artboard at a print resolution, e.g. the maximum 16383 pt artboard at 300 ppi (~68 000 px), or a screenshot at scale 16, panicked inside vello_common: the desktop app or the MCP server exited and unsaved work was lost. `vectorcraft_render::raster_size` checks the pixel size first (at most 32 768 px a side and 268 megapixels, like Rasterize already refuses oversized images) and the export paths return an error that names the size: `document.export` / `exportSelection` / `serialize`, the MCP `export` and `screenshot` tools, File ▸ Export and the control protocol's `ui.render`. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
604c20ed90
commit
152228d76d
@@ -134,7 +134,9 @@ fn encode_doc_with(doc: &vectorcraft_doc::Document, format: &str, scale: f64, ar
|
||||
"pdf" => super::rasterfx::export_pdf(doc, &vectorcraft_pdf::PdfOptions::default()).map_err(|e| EngineError::Other(e.to_string()))?,
|
||||
"png" | "jpg" | "jpeg" | "webp" => {
|
||||
let r = doc.artboards.get(artboard).map(|a| a.rect).ok_or_else(|| EngineError::Other("no such artboard".into()))?;
|
||||
let img = vectorcraft_render::Renderer::new().render_region(doc, r, scale.clamp(0.01, 64.0), format != "png" && format != "webp");
|
||||
let scale = scale.clamp(0.01, 64.0);
|
||||
vectorcraft_render::raster_size(r, scale).map_err(EngineError::Other)?;
|
||||
let img = vectorcraft_render::Renderer::new().render_region(doc, r, scale, format != "png" && format != "webp");
|
||||
match format {
|
||||
"png" => img.to_png(),
|
||||
"webp" => img.to_webp(),
|
||||
|
||||
Reference in New Issue
Block a user