Portable JPEG-LS lossless and near-lossless image coding
moon check --target all --deny-warn
moon test --target wasm --deny-warn
moon test --target wasm-gc --deny-warn
moon test --target js --deny-warn
moon run cmd/demo --target js
moon fmt --checknode scripts/moonjls.mjs encode input.pgm output.jls
node scripts/moonjls.mjs encode input.ppm output.jls --near 3 --interleave line
node scripts/moonjls.mjs inspect output.jls
node scripts/moonjls.mjs decode output.jls restored.pnm
node scripts/moonjls.mjs decode output.jls restored.pam --pamlet original : @jls.Image = {
frame: { width: 2, height: 2, bits_per_sample: 12, components: 1 },
samples: [0, 4095, 73, 2048],
}
let packed = @jls.encode(original)
let restored = @jls.decode(packed[:])let options = { ..@jls.EncodeOptions::default(), near: 3 }
let packed = @jls.encode(original, options~)python -m pip install --target work/pydeps -r scripts/requirements-dev.txt
python scripts/interop.pypython scripts/validate.pypython scripts/count_loc.py
python scripts/count_loc.py --minimum 4000pub(all) suberror JlsError {
Invalid(Int, String)
Truncated(Int, String)
Unsupported(Int, String)
Limit(Int, String)
}fn ByteSource::slice(self : ByteSource, offset : UInt64, length : UInt64) -> ByteSource raise JlsErrorpub struct CodestreamFramer {
limits : Limits
batch_images : Int
buffer : Buffer
state : FramingState
marker : Int
length : Int
remaining : Int
images : UInt64
received : UInt64
closed : Bool
failed : Bool
}fn CodestreamFramer::feed(self : CodestreamFramer, chunk : BytesView) -> Array[Bytes] raise JlsErrorpub(all) struct EncodeOptions {
near : Int
interleave : Interleave
preset : Preset
} derive(Eq, Debug)pub(all) struct ErrorMetrics {
samples : Int
maximum_error : Int
mean_error : Double
mean_absolute_error : Double
mean_squared_error : Double
channels : Array[ChannelMetrics]
} derive(Eq, Debug)pub(all) struct PixelLayout {
order : PixelOrder
storage : SampleStorage
row_stride : Int
plane_stride : Int
} derive(Eq, Debug)pub struct PnmSource {
source : ByteSource
frame : Frame
maximum : Int
raster_offset : UInt64
row_bytes : Int
sample_bytes : Int
limits : Limits
}fn PnmSource::open(source : ByteSource, start? : UInt64, limits? : Limits) -> PnmSource raise JlsErrorpub(all) struct RatePoint {
near : Int
interleave : Interleave
compressed_bytes : Int
maximum_error : Int
mean_squared_error : Double
} derive(Eq, Debug)fn RowEncoder::new(frame : Frame, emit : (Bytes) -> Unit raise JlsError, options? : EncodeOptions, limits? : Limits) -> RowEncoder raise JlsErrorfn SampleHistogram::count(self : SampleHistogram, component : Int, value : Int) -> Int raise JlsErrorfn SampleHistogram::new(bits : Int, components : Int, maximum_samples? : Int) -> SampleHistogram raise JlsErrorfn SampleHistogram::nonzero_bins(self : SampleHistogram, component : Int, maximum_bins? : Int) -> Array[(Int, Int)] raise JlsErrorfn SampleHistogram::push_image(self : SampleHistogram, image : Image, limits? : Limits) -> Unit raise JlsErrorfn SampleHistogram::quantile(self : SampleHistogram, component : Int, probability : Double) -> Int raise JlsErrorfn SampleHistogram::subtract(self : SampleHistogram, other : SampleHistogram) -> Unit raise JlsErrorfn SampleHistogram::summary(self : SampleHistogram, component : Int) -> SampleSummary raise JlsErrorpub(all) struct ScanInfo {
components : Array[Int]
near : Int
interleave : Interleave
preset : Preset
entropy_offset : Int
entropy_end : Int
restart_interval : Int
} derive(Eq, Debug)fn compare_images(expected : Image, actual : Image, limits? : Limits) -> ErrorMetrics raise JlsErrorfn encode_restarted(image : Image, interval : Int, options? : EncodeOptions, limits? : Limits) -> Bytes raise JlsErrorfn encode_to_budget(image : Image, maximum_bytes : Int, near_levels : Array[Int], modes : Array[Interleave], maximum_attempts? : Int, work_sample_budget? : UInt64, limits? : Limits) -> EncodingChoice? raise JlsErrorfn encode_transformed(image : Image, transform : ColorTransform, options? : EncodeOptions, limits? : Limits) -> Bytes raise JlsErrorfn verify_near(expected : Image, actual : Image, near : Int, limits? : Limits) -> ErrorMetrics raise JlsErrorInstall
Download zipPortable JPEG-LS lossless and near-lossless image coding