Skip to content

svga v0.1.1

Choose a tag to compare

@WendellXY WendellXY released this 19 Sep 06:13
· 3 commits to main since this release

Additive release: nothing existing changes shape. These came out of moving the first consumer's optimizer and renderer onto the crate.

Added

  • Document::replace_image_at and Document::remove_image_at address an entry by its position in images(). They reach what the &str-keyed edits cannot name: repeated keys, and keys that are not valid UTF-8. Out of range is InvalidEdit("svga_image_index_out_of_range").
  • Animation::into_movie hands over the typed movie and releases the file's images and buffers. Fetch the images you need through Animation::image first.
  • Animation::image_kind(key) sniffs the bytes Animation::image resolves, so it also works for SVGA 1.x and zipped files.
  • svga::png_dimensions(bytes) reads width and height from a PNG header. No pixels are decoded.
  • ValueKind::Jpeg for values starting with a JPEG start-of-image marker.

Behaviour note

A JPEG image value used to sniff as ValueKind::Unknown and now sniffs as ValueKind::Jpeg. Code that treats "not a PNG" as Unknown should test != ValueKind::Png instead. The enum is #[non_exhaustive], so this compiles unchanged.

Documentation

  • Document::from_bytes walks the whole payload up front, so a malformed file is reported as malformed even if it also contains things a caller would refuse on policy grounds.
  • ValueKind is an ordered heuristic: short text starting with ID3 reads as Mp3, and an empty value is Unknown.