svgdiff-raster-codec

    Bounded PNG and baseline JPEG decoding for svgdiff embedded resources.

    Download zip
    Author
    Version
    0.1.2
    License
    Apache-2.0
    Last updated
    14 days ago
    Downloads
    124

    Dependencies

    #svgdiff-raster-codec

    Project-owned bounded 8-bit non-interlaced PNG and single-scan baseline JPEG decoding plus format-level color-metadata inspection for embedded SVG raster resources.

    The decoder is derived from mizchi/image@0.1.2 under Apache-2.0. The public surface is intentionally narrow: RGBA8 output plus caller-provided dimension and pixel bounds, and read-only PNG/JPEG color metadata classified as sRGB-compatible, embedded-profile, or HDR/high-bit-depth. Inspection validates container structure and reports intrinsic dimensions without converting pixels. PNG decompression is capped at the exact validated scanline size. PNG variants with unimplemented transparency, physical-size, orientation, unknown-chunk, or animation semantics are rejected; JPEG is limited to grayscale, 4:4:4, and 4:2:0 baseline sampling.

    DecodeError

    pub(all) suberror DecodeError {
    InvalidSignature(String)
    InvalidChunkCrc(String)
    MissingChunk(String)
    UnsupportedFeature(String)
    CorruptData(String)
    DecodeLimitExceeded(String)
    }

    impl Show for DecodeError

    DecodeError::output

    fn DecodeError::output(self : DecodeError, logger : &Logger) -> Unit

    DecodeError::to_string

    fn DecodeError::to_string(self : DecodeError) -> String

    ImageData

    pub(all) struct ImageData {
    width : Int
    height : Int
    data : Bytes
    } derive(Eq)

    ImageData::equal

    fn ImageData::equal(ImageData, ImageData) -> Bool

    ImageData::not_equal

    fn ImageData::not_equal(x : ImageData, y : ImageData) -> Bool

    RasterColorCondition

    pub(all) enum RasterColorCondition {
    SrgbCompatible
    EmbeddedColorProfile(String)
    HdrOrHighBitDepth(String)
    } derive(Eq,
    Debug
    )

    RasterColorCondition::equal

    RasterColorCondition::not_equal

    RasterColorMetadata

    pub(all) struct RasterColorMetadata {
    width : Int
    height : Int
    condition : RasterColorCondition
    } derive(Eq,
    Debug
    )

    RasterColorMetadata::equal

    RasterColorMetadata::not_equal

    decode_jpeg_bounded

    fn decode_jpeg_bounded(data : Bytes, max_dimension~ : Int, max_pixels~ : Int) -> ImageData raise DecodeError

    decode_png_bounded

    fn decode_png_bounded(raw : Bytes, max_dimension~ : Int, max_pixels~ : Int) -> ImageData raise DecodeError

    inspect_jpeg_color_metadata

    fn inspect_jpeg_color_metadata(data : Bytes) -> RasterColorMetadata raise DecodeError

    inspect_png_color_metadata

    fn inspect_png_color_metadata(raw : Bytes) -> RasterColorMetadata raise DecodeError

    Powered by MoonBit

    Site sourceReport issuePackagesBuild queueSkillsStatistics

    © 2026 mooncakes.io