Every print shop and frontend engineer eventually hits the same two logo files from a client or founder:
- A "vector logo" exported from Illustrator, Inkscape, or Sketch that weighs 18 KB for four simple shapes — stuffed with
xmlns:inkscape,sodipodi:namedview,data-name,<metadata>, empty nested<g>wrappers, 7-decimal coordinates (142.8571429), and occasionally even an inline<script>oronloadattribute from a third-party template. - A 500 × 500 px PNG that looks razor-sharp inside a Slack avatar — right up until a commercial printer rejects it because at 300 DPI it can only print 1.67 × 1.67 inches before visibly pixelating on a 3.5 × 2 inch business card or 11-inch T-shirt chest print.
Neither problem should require uploading proprietary brand files to a third-party server or installing desktop CAD tooling. We built two zero-upload, pure-TypeScript browser tools at LogoNib — a Client-Side SVG Optimizer & Cleaner and a Print Logo DPI & Physical Size Checker — that run 100% locally in the browser with zero account gates and zero server uploads.
Here is how both engines work under the hood, and the subtle edge cases that break naive regex minifiers.
1. Security First: Sanitizing Untrusted SVGs Before Rendering
Unlike PNG or JPEG, an SVG file is an executable XML document. If you accept a user-uploaded .svg and render it via innerHTML or an image/svg+xml Blob URL on your own origin, an attacker can execute arbitrary JavaScript inside your origin via:
-
<script>...</script>elements -
<foreignObject>HTML injection - Inline event handlers (
onload=,onclick=,onerror=,onbegin=) - Dangerous
href/xlink:hrefschemes (javascript:,data:text/html)
Our Client-Side SVG Optimizer & Cleaner enforces two invariants simultaneously:
- Always-on active content stripping: Regardless of which visual cleanup toggles a user turns on or off, the sanitizer strips
<script>,<foreignObject>, allon*event attributes, andjavascript:/data:text/htmllinks — and counts every stripped vector element explicitly in the report. - Never render user SVG in the live DOM: Instead of injecting raw markup into the page, the browser rasterizes the sanitized SVG into a static PNG via an off-screen canvas (
renderSvgToPngBytes) so the live Light / Dark / Checkerboard preview can never execute markup.
2. Why Naive Number Rounding Corrupts SVGs
Once active content, XML comments (<!-- ... -->), <?xml?> prologs, <!DOCTYPE>, <metadata>, and editor namespaces (xmlns:inkscape, xmlns:sodipodi, xmlns:sketch, inkscape:*, sodipodi:*, data-name) are removed, the single largest remaining byte savings comes from coordinate precision rounding.
Desktop vector tools routinely write floating-point paths like:
<path d="M 12.000001 48.3333333 L 96.4999999 48.3333333 C 110.123456 48.3333333 120.987654 58.123456 120.987654 72.000000 Z" /> Rounding coordinates to 2 decimal places (12 48.33 L 96.5 48.33 ...) typically cuts path string size by 40% to 70% with zero human-visible geometry drift at any print or screen scale.
The trap: If you blindly run a global float-rounding regex across the entire SVG string, you will corrupt:
-
viewBox="0 0 100.5 100.5"(rounding a tight integer or fractional viewBox shifts clipping boundaries) -
version="1.1"(turning1.1into1if precision is0) - Text content or
opacity="0.125"values
Instead, our optimizer targets geometry attributes specifically — d, points, x, y, x1, y1, x2, y2, cx, cy, r, rx, ry, width, height, stroke-width — while leaving viewBox, version, and non-geometric attributes untouched, and iteratively collapsing empty <g> groups bottom-up (<g><g></g></g> -> removed in two passes).
On a realistic Illustrator logo export (~1.96 KB), enabling precision 2 + metadata/editor stripping cuts the file to 483–609 bytes (69%–76% smaller) in under 2 milliseconds — and runs our SVG Font Outline Pre-Flight Checker simultaneously to warn if any live <text> tags are still waiting to break at the print shop.
3. Exact 300-DPI Pre-Press Math for US Commercial Print Specs
The other half of print rejections is simpler mathematically, yet catches thousands of small businesses ordering signage, packaging, and apparel: effective print DPI.
Effective DPI = min(pixelWidth / printWidthInches, pixelHeight / printHeightInches) And the maximum safe physical print width at a target DPI is:
Max Safe Inches = pixelDimension / targetDPI Different physical substrates require very different effective DPI thresholds because viewing distance varies:
| Print Deliverable | Typical Logo Area | Target DPI | Min Pixels Needed |
|---|---|---|---|
Business Card (3.5" × 2") | 1.5" × 0.75" | 300 DPI | 450 × 225 px |
| Letterhead / Invoice Header | 2.0" × 0.75" | 300 DPI | 600 × 225 px |
| Product Packaging / Sticker | 3.0" × 3.0" | 300 DPI | 900 × 900 px |
| Left-Chest Embroidery / Screen Print | 4.0" × 4.0" | 300 DPI | 1200 × 1200 px |
| Full-Front T-Shirt Print | 11.0" × 11.0" | 300 DPI | 3300 × 3300 px |
| Trade-Show Retractable Banner | 30.0" × 12.0" | 150 DPI | 4500 × 1800 px |
| 6-Foot Vinyl Backdrop / Signage | 48.0" × 18.0" | 100 DPI | 4800 × 1800 px |
In the Print Logo DPI & Physical Size Checker, dropping any PNG, JPG, WebP, or SVG immediately inspects native dimensions in-browser, computes effective DPI across all 10 US commercial print presets (plus custom dimensions in inches or mm), and classifies every deliverable as PASS (>= target), WARN (75%–99% of target), or FAIL (< 75%).
- If you drop an SVG, every single preset evaluates to Infinite Vector Resolution (PASS) — because mathematical Bézier paths rasterize cleanly at 300 DPI whether on a 1-inch stamp or a 6-foot trade-show banner.
- If a raster PNG fails 300 DPI, the tool surfaces an instant bridge to our free client-side PNG to SVG Vector Tracer (or our SVG to Print-Ready PDF Converter with
0.125"bleed and crop marks) so you can fix the file immediately without leaving the browser.
Try Both Tools Free (No Signup, Zero Upload)
- Client-Side SVG Optimizer & Cleaner — sanitize active SVG markup, strip Illustrator/Inkscape/Sketch bloat, round path precision, verify pre-press outlined
<path>compliance, and download.min.svglocally. - Print Logo DPI & Physical Size Checker — check any PNG, JPG, WebP, or SVG against 10 US commercial print standards (business cards, stickers, apparel, banners) and get exact max safe inches/mm at 300, 150, and 100 DPI.
- All 14 Free Browser Brand Engineering Tools — including PNG-to-SVG tracing, background removal, CMYK/WCAG conversion, favicon packing, and business card PDF generation.
- Need a brand-new logo built from scratch as mathematically outlined vector geometry (
.svg, 300-DPI vector.pdf, CMYK brand guide, favicons, and social pack,$29–$89one-time with zero subscriptions)? Try the free interactive studio at LogoNib.
