module

DataDungeon::WebP

Constants

QUALITY = 85_f32

Class methods

convert!(path : String, quality : Float32 = QUALITY) : String

In-place conversion: writes .webp sibling, deletes the original, returns new path.

Source
decode_png(png_path : String) : Tuple(Int32, Int32, Bytes)

Decode a PNG file to raw RGBA pixels: {width, height, rgba_bytes}. Through ImageProbe's reader, which turns a bad file into an error; libpng's own reader, used here before 0.16.2, aborted the process.

Source
encode(png_path : String, webp_path : String, quality : Float32 = QUALITY) : Int64

Convert a PNG file to WebP. Returns the new .webp path.

Source
encode_webp(rgba : Bytes, width : Int32, height : Int32, webp_path : String, quality : Float32 = QUALITY) : Int64

Encode RGBA pixels to a WebP file. Returns output file size in bytes.

Source
encode_webp_bytes(rgba : Bytes, width : Int32, height : Int32, quality : Float32 = QUALITY) : Bytes

Encode RGBA pixels to WebP in memory. Returns the encoded bytes.

Source
png_to_webp_bytes(png : Bytes, quality : Float32 = QUALITY) : Bytes

Convert PNG bytes to WebP bytes.

Source