Comments (12)
Is there a way to toggle which decoders are compiled, or some way to toggle them at runtime?
In many cases it would be nice to disable PSD support either to reduce attack surface (e.g. an image format converter accepting untrusted input) or just not to advertise support for a format that is not complete (e.g. in a desktop image viewer). PSD is an immensely complex format, and full support for it is a multi-year effort.
Added is_experimental
method to DecoderTrait
, (DecoderTrait
allows unanimous image decoding from multiple formats into a single image, i.e. implemented for all image decoders).
And added an --experimental
flag in the command line, this adds a guard on all decoders which are experimental(currently farbfeld and psd) to require --experimental
flag in the command line before decoding.
from zune-image.
@Shnatsel , Finished a simple PNG decoder.
Doesn't do a lot yet, only works with 8 bpp pixel images but I think you'll love the speeds at
https://github.com/etemesi254/zune-image/blob/main/zune-png/Benches.md
Uses a custom zlib decoder at zune-inflate
which is as fast as zlib-ng
(for the tests I've done, which is extracting delfate chunks from a png image of your AI upscaled image from before, running decode on it) and about 20Mb/s faster than miniz-oxide(using the same procedure).
The speedups actually don't even come from that.
They come from a carefully written filter algorithm which the compiler can optimize, and that's pretty sweet(will probably write a blog post about it soon) but for now that's all.
Will work on finishing this and the jpeg decoder for now
from zune-image.
cc @Shnatsel , PSD decoding landed(limited in scope, not fully working), thought you might be interested.
from zune-image.
Is there a way to toggle which decoders are compiled, or some way to toggle them at runtime?
In many cases it would be nice to disable PSD support either to reduce attack surface (e.g. an image format converter accepting untrusted input) or just not to advertise support for a format that is not complete (e.g. in a desktop image viewer). PSD is an immensely complex format, and full support for it is a multi-year effort.
from zune-image.
PNG also has an animated variant, APNG, which is now supported by all web browsers as well as the Rust png
and image
crates. It would be nice to support that as well eventually.
from zune-image.
from zune-image.
Is there a way to toggle which decoders are compiled, or some way to toggle them at runtime?
In many cases it would be nice to disable PSD support either to reduce attack surface (e.g. an image format converter accepting untrusted input) or just not to advertise support for a format that is not complete (e.g. in a desktop image viewer). PSD is an immensely complex format, and full support for it is a multi-year effort.
zune-image
supports ability to disable , I'm yet to add that to the binary.
For PSD complexity you make an interesing case,
Just found out ffmpeg supports PSD files, i.e https://github.com/FFmpeg/FFmpeg/blob/master/libavcodec/psd.c that's their implementation.
ImageMagick's one is longer since it supports more features i.e
The I was using stb as a basis for my PSD implementation. about 246 LOC at https://github.com/nothings/stb/blob/8b5f1f37b5b75829fc72d38e7b5d4bcbf8a26d55/stb_image.h#L6002-L6248.
Currently we throw out a lot of data we don't need, i.e layers and such to just get the image, the same with ffmpeg and stb. Imagemagick does not do this, and the features it implements aren't
I'd rather not disable it, for the command line and add it under a feature , say --unsafe
is needed to decode PSD files since it's experimental at best than trying to chase perfection since that will mean this library will never be ready for any real world decoding.
from zune-image.
Is the BMP format in scope? It should be relatively trivial, but I don't see it mentioned explicitly.
from zune-image.
Hi, BMP support is planned.
The plan is to support at least anything image-rs supports first.(Like farbfeld decode support landed but can't currently be encoded, working on that one over the weekend).
This issue should probably be restructured in the way it is(I.e tracking image status and planned times )
from zune-image.
That's excellent news, thanks for sharing!
I'm curious, how does zune-inflate
compare to libdeflate
performance-wise?
Also, I should have mentioned it earlier, but WUFFS has a fast PNG decoder and detailed explanation of why it's fast, and there's also libspng that beats libpng. You might be able to lift some tricks from those and push performance even further.
from zune-image.
Perfomance wise with libdeflate
, zune-inflate
is probably a 1 to 1 translation of libdeflate with some small language differences, will put up performance comparisions soon, but in face value I expect libdeflate
to be slightly faster because it can take advantage of some C properties like incrementing pointers,unbound checks,some union hackery and some wrapping subtractions on steroids, which I didn't implement as it made some asserts hard to do in some places.
Didn't know about libspng
let me check it out.
Also looking at wuffs
.
Will cc you when I think it's ready for fuzz-testing
from zune-image.
FWIW what I've been doing so far is testing on real-world images instead of fuzz testing. Fuzzing produces random/invalid data to trigger unexpected codepaths, like panics or memory safety bugs.
Fuzzing usually finds a large amount of rather boring panics, so I've put it off until the correctness on real-world images is established.
from zune-image.
Related Issues (20)
- JPEG: image decoded incorrectly HOT 1
- Channel::new_with_length is not generally sound HOT 13
- Channel without type_id leads to unsound use
- Channel::push has an overflow bug leading to unsoundness
- Zune Inflate: Fails to decode zlib-compressed binary data HOT 1
- JPEG XL: zune produces files that libjxl fails to decode HOT 1
- JPEG XL: zune encodes some images incorrectly HOT 5
- zune-jpeg: decode to BGR/BGRA image HOT 6
- Add zlib license as a license option HOT 3
- PNG: regression after 0.1.0: some images are garbled
- JPEG XL: zune encodes some images incorrectly
- `de_filter_sub3_sse2` calls the inner function without a check HOT 2
- Expand with alpha channel during decoding HOT 20
- DecoderOptions::get_bye_endian typo HOT 1
- new_with_options is inconsistent between PNG and JPEG HOT 2
- Where is Y-flipping? HOT 5
- zune-jpeg: noisy log spam HOT 4
- `zune-jpeg` 2x slower than `image` crate on my M1 MacBook HOT 4
- `zune-jpeg` Decoding to Luma colorspace gives bad results HOT 5
- MJPG decoding: Error decoding huffman values: No DC table for component Y HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from zune-image.