Skip to content

PNG export rejects the fractional scale documented for exact pixel sizes #299

Description

@rudycelekli

The PNG reference explicitly recommends a fractional device scale (target_width / viewBox_width, e.g. 1.25) for exact requested pixel sizes, but its Rasterize snippet parses the third argument with int(). The exact snippet fails immediately with ValueError for a valid 1.25; its ordinary scale2 control captures successfully.

Proposed scope: parse finite scale multipliers consistently with the documented 1–4 range, preserve default/integer scales, and add native browser tests that verify exact output dimensions for fractional requested sizes plus invalid argument controls. No extra scaling capability beyond the existing reference, no source diagram change, and no plugin version bump.

Codex is assisting @rudycelekli.

Activity

  1. rudycelekli commented on Oct 6, 2026

    @rudycelekli
    ContributorAuthor

    The same exact-size contract also fails on shipped page CSS, even for integer scales. In actual Chromium 151, example-architecture.html has viewBox 1000×480 but a CSS bounding box of 1200×576. Its @2 PNG is therefore 2400×1152 rather than the documented 2000×960. The current fixed-size test fixture hid that discrepancy.

    I am grouping this into this exact-sizing fix: accept the documented finite fractional scales and establish the SVG capture viewport from its nonzero finite viewBox dimensions before applying the multiplier. Keep ancestor overflow release, the source file, aspect ratio, default2/integer outputs, and fallback/error behavior intact. Native tests will also include a deliberately oversized page-CSS viewport and malformed/zero viewBox rejection; this is one exact-sizing PR, not a separate submission.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions