brave-intl / wasm-thumbnail

WASM image thumbnail resizing library
Mozilla Public License 2.0
5 stars 8 forks source link

Reject .webp inputs #7

Open fmarier opened 3 years ago

fmarier commented 3 years ago

The ideal workflow for users of this component is:

  1. User uploads a JPEG|GIF|PNG
  2. wasm-thumbnail converts to WEBP

so that we are guaranteed not to host the exact bytes that a user uploaded (i.e. we force a conversion between image formats).

At the moment, the Rust code will accept input images in any of the supported formats.

tackley commented 3 years ago

Sadly the only rust library I can find that supports writing webp is this one, which is actually a thin wrapper over google's libwebp C library.

Which means it cannot be used from within a wasm - and arguably defeats the point somewhat of having this image processing in rust.

fmarier commented 3 years ago

Good find Graham. I guess we won't be able to implement the ideal workflow in a straightforward way.

Let's just remove webp from wasm-thumbnail entirely for now.

fmarier commented 3 years ago

From @tackley:

The C library would be needed to write webp; reading webp is pure rust. See https://github.com/image-rs/image/blob/master/src/codecs/webp/decoder.rs.