diff --git a/src/decoding.jl b/src/decoding.jl index e423311..eedea5a 100644 --- a/src/decoding.jl +++ b/src/decoding.jl @@ -18,8 +18,21 @@ function decode( else throw(ArgumentError("Unsupported color type: $TColor")) end + + bitstream_features = Ref{Wrapper.WebPBitstreamFeatures}() + # WebPGetFeatures is not available in libwebp dynamic library, but WebPGetFeaturesInternal is equivalent: https://github.com/webmproject/libwebp/blob/v1.4.0/src/webp/decode.h#L441 + Wrapper.WebPGetFeaturesInternal( + pointer(data), length(data), bitstream_features, Wrapper.WEBP_DECODER_ABI_VERSION + ) width = Ref{Int32}(-1) height = Ref{Int32}(-1) + if bitstream_features[].has_animation == 1 + @warn("Animated WebP not supported") + WebPGetInfo(pointer(data), length(data), width, height) + image = + transpose ? ones(TColor, width[], height[]) : ones(TColor, height[], width[]) + return image + end decoded_data_ptr = webp_decode_fn(pointer(data), length(data), width, height) decoded_data_size = (sizeof(TDecodedColor), Int(width[]), Int(height[])) decoded_data = unsafe_wrap(Array{UInt8, 3}, decoded_data_ptr, decoded_data_size) diff --git a/test/decoding_tests.jl b/test/decoding_tests.jl index dd7d571..e7f7c61 100644 --- a/test/decoding_tests.jl +++ b/test/decoding_tests.jl @@ -26,6 +26,10 @@ using WebP "5_webp_ll.webp" => (300, 300), ), ), + animation = ( + url = "https://storage.googleapis.com/downloads.webmproject.org/webp/images/", + data = Dict("dancing_banana2.lossless.webp" => (1050, 990)), + ), ) for gallery in webp_galleries for (filename, image_size) in gallery.data