From c1af556751e196aba1f66aa06ce36f00d07d7ca7 Mon Sep 17 00:00:00 2001 From: Přemysl Eric Janouch
Date: Tue, 28 Dec 2021 19:37:15 +0100 Subject: Load back wide thumbnail metadata --- fiv-io.c | 10 +++++++++- fiv-io.h | 2 ++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/fiv-io.c b/fiv-io.c index dfea508..26b6e89 100644 --- a/fiv-io.c +++ b/fiv-io.c @@ -1718,6 +1718,7 @@ open_libwebp(const gchar *data, gsize len, const gchar *path, } // Releasing the demux chunk iterator is actually a no-op. + // TODO(p): Avoid copy-pasting the chunk transfer code. WebPChunkIterator chunk_iter = {}; uint32_t flags = WebPDemuxGetI(demux, WEBP_FF_FORMAT_FLAGS); if ((flags & EXIF_FLAG) && @@ -1741,6 +1742,12 @@ open_libwebp(const gchar *data, gsize len, const gchar *path, (cairo_destroy_func_t) g_bytes_unref); WebPDemuxReleaseChunkIterator(&chunk_iter); } + if (WebPDemuxGetChunk(demux, "THUM", 1, &chunk_iter)) { + cairo_surface_set_user_data(result, &fiv_io_key_thum, + g_bytes_new(chunk_iter.chunk.bytes, chunk_iter.chunk.size), + (cairo_destroy_func_t) g_bytes_unref); + WebPDemuxReleaseChunkIterator(&chunk_iter); + } if (flags & ANIMATION_FLAG) { cairo_surface_set_user_data(result, &fiv_io_key_loops, (void *) (uintptr_t) WebPDemuxGetI(demux, WEBP_FF_LOOP_COUNT), @@ -2280,6 +2287,7 @@ cairo_user_data_key_t fiv_io_key_exif; cairo_user_data_key_t fiv_io_key_orientation; cairo_user_data_key_t fiv_io_key_icc; cairo_user_data_key_t fiv_io_key_xmp; +cairo_user_data_key_t fiv_io_key_thum; cairo_user_data_key_t fiv_io_key_frame_next; cairo_user_data_key_t fiv_io_key_frame_previous; @@ -2981,7 +2989,7 @@ static cairo_surface_t * read_wide_thumbnail( const gchar *path, const gchar *uri, time_t mtime, GError **error) { - // TODO(p): Validate. + // TODO(p): Validate fiv_io_key_thum. (void) uri; (void) mtime; return fiv_io_open(path, NULL, FALSE, error); diff --git a/fiv-io.h b/fiv-io.h index b561286..52fd691 100644 --- a/fiv-io.h +++ b/fiv-io.h @@ -47,6 +47,8 @@ extern cairo_user_data_key_t fiv_io_key_orientation; extern cairo_user_data_key_t fiv_io_key_icc; /// GBytes with plain XMP data. extern cairo_user_data_key_t fiv_io_key_xmp; +/// GBytes with a WebP's THUM chunk, used for our thumbnails. +extern cairo_user_data_key_t fiv_io_key_thum; /// The next frame in a sequence, as a surface, in a chain, pre-composited. /// There is no wrap-around. -- cgit v1.2.3-70-g09d2