svgdiff-raster-codec

Bounded PNG and baseline JPEG decoding for svgdiff embedded resources.

moon add Milky2018/svgdiff-raster-codec@0.1.1
Download zip
Author
Version
0.1.1
License
Apache-2.0
Last updated
5 days ago
Downloads
93

Dependencies

README

#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

#
ImageData

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

#
RasterColorCondition

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

#
RasterColorMetadata

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

#
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