From: Colin Clark Date: Mon, 13 Mar 2023 14:13:19 +0000 (+0000) Subject: Use webp-pixbuf-loader instead of image-load-webp() X-Git-Tag: v2.1~97 X-Git-Url: http://geeqie.org/cgi-bin/gitweb.cgi?p=geeqie.git;a=commitdiff_plain;h=c3f081ff535df3fc3fdb8dada69c70a10d3bee6a Use webp-pixbuf-loader instead of image-load-webp() webp-pixbuf-loader also supports animation --- diff --git a/config.h.in b/config.h.in index e356592c..990920cb 100644 --- a/config.h.in +++ b/config.h.in @@ -110,10 +110,6 @@ /* Define to enable use of custom tiff loader */ #mesondefine HAVE_TIFF -/* Define to enable webp support */ -#mesondefine HAVE_WEBP - - /* Version number of package */ #mesondefine VERSION diff --git a/doxygen.conf b/doxygen.conf index 7676c174..97a5c40d 100644 --- a/doxygen.conf +++ b/doxygen.conf @@ -2279,8 +2279,7 @@ PREDEFINED = DEBUG=1 \ HAVE_PDF=1 \ HAVE_RAW=1 \ HAVE_SPELL=1 \ - HAVE_TIFF=1 \ - HAVE_WEBP=1 + HAVE_TIFF=1 # If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then this # tag can be used to specify a list of macro names that should be expanded. The diff --git a/geeqie-install-debian.sh b/geeqie-install-debian.sh index 9b018545..1412e298 100755 --- a/geeqie-install-debian.sh +++ b/geeqie-install-debian.sh @@ -8,7 +8,7 @@ ## Dialogs allow the user to install additional features. ## -version="2022-07-30" +version="2023-03-11" description=' Geeqie is an image viewer. This script will download, compile, and install Geeqie on Debian-based systems. @@ -71,8 +71,8 @@ libimage-exiftool-perl (for jpeg extraction plugin) libimage-exiftool-perl libheif (for HEIF support) libheif-dev -libwebp (for WebP images) -libwebp-dev +webp-pixbuf-loader (for WebP images) +webp-pixbuf-loader libdjvulibre (for DjVu images) libdjvulibre-dev libopenjp2 (for JP2 images) diff --git a/meson.build b/meson.build index 2091bdec..2f136d6b 100644 --- a/meson.build +++ b/meson.build @@ -485,19 +485,15 @@ else summary({'videothumbnailer' : ['disabled -thumbnails of video files supported', false]}, section : 'Configuration', bool_yn : true) endif -libwebp_dep = [] -req_version = '>=0.6.1' -option = get_option('webp') -if not option.disabled() - libwebp_dep = dependency('libwebp', version : req_version, required : get_option('webp')) - if libwebp_dep.found() - conf_data.set('HAVE_WEBP', 1) - summary({'webp' : ['webp files supported:', true]}, section : 'Configuration', bool_yn : true) - else - summary({'webp' : ['libwebp ' + req_version + ' not found - webp files supported:', false]}, section : 'Configuration', bool_yn : true) - endif +# libpixbufloader-webp is not loaded as part of libgdk-pixbuf. Just issue +# a warning if not installed +libwebp_dir = dependency('gdk-pixbuf-2.0', method: 'pkg-config').get_variable('gdk_pixbuf_moduledir') +libwebp_dep = cc.find_library('libpixbufloader-webp', dirs : libwebp_dir, required : false) + +if libwebp_dep.found() + summary({'webp' : ['webp files supported:', true]}, section : 'Configuration', bool_yn : true) else - summary({'webp' : ['disabled - webp files supported:', false]}, section : 'Configuration', bool_yn : true) + summary({'webp' : ['webp-pixbuf-loader not installed - webp files supported:', false]}, section : 'Configuration', bool_yn : true) endif # Check for nl_langinfo and _NL_TIME_FIRST_WEEKDAY diff --git a/meson_options.txt b/meson_options.txt index 3b272f2a..f786bdc4 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -43,5 +43,4 @@ option('pdf', type : 'feature', value : 'auto', description : 'pdf') option('spell', type : 'feature', value : 'auto', description : 'spelling checks') option('tiff', type : 'feature', value : 'auto', description : 'tiff') option('videothumbnailer', type : 'feature', value : 'auto', description : 'video thumbnailer') -option('webp', type : 'feature', value : 'auto', description : 'webp') option('yelp-build', type : 'feature', value : 'auto', description : 'help files') diff --git a/scripts/geeqie.cppcheck b/scripts/geeqie.cppcheck index 3dcf3dfd..4ba0de39 100644 --- a/scripts/geeqie.cppcheck +++ b/scripts/geeqie.cppcheck @@ -36,7 +36,6 @@ - ENABLE_NLS diff --git a/src/image-load-webp.cc b/src/image-load-webp.cc deleted file mode 100644 index af38e39d..00000000 --- a/src/image-load-webp.cc +++ /dev/null @@ -1,152 +0,0 @@ -/* - * Copyright (C) 20019 - The Geeqie Team - * - * Author: Colin Clark - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#include "main.h" - -#include "image-load.h" -#include "image-load-webp.h" - -#ifdef HAVE_WEBP -#include - -typedef struct _ImageLoaderWEBP ImageLoaderWEBP; -struct _ImageLoaderWEBP { - ImageLoaderBackendCbAreaUpdated area_updated_cb; - ImageLoaderBackendCbSize size_cb; - ImageLoaderBackendCbAreaPrepared area_prepared_cb; - gpointer data; - GdkPixbuf *pixbuf; - guint requested_width; - guint requested_height; - gboolean abort; -}; - -static void free_buffer(guchar *pixels, gpointer UNUSED(data)) -{ - g_free(pixels); -} - -static gboolean image_loader_webp_load(gpointer loader, const guchar *buf, gsize count, GError **UNUSED(error)) -{ - ImageLoaderWEBP *ld = (ImageLoaderWEBP *) loader; - guint8* data; - gint width, height; - gboolean res_info; - WebPBitstreamFeatures features; - VP8StatusCode status_code; - - res_info = WebPGetInfo(buf, count, &width, &height); - if (!res_info) - { - log_printf("warning: webp reader error\n"); - return FALSE; - } - - status_code = WebPGetFeatures(buf, count, &features); - if (status_code != VP8_STATUS_OK) - { - log_printf("warning: webp reader error\n"); - return FALSE; - } - - if (features.has_alpha) - { - data = WebPDecodeRGBA(buf, count, &width, &height); - } - else - { - data = WebPDecodeRGB(buf, count, &width, &height); - } - - ld->pixbuf = gdk_pixbuf_new_from_data(data, GDK_COLORSPACE_RGB, features.has_alpha, 8, width, height, width * (features.has_alpha ? 4 : 3), free_buffer, NULL); - - ld->area_updated_cb(loader, 0, 0, width, height, ld->data); - - return TRUE; -} - -static gpointer image_loader_webp_new(ImageLoaderBackendCbAreaUpdated area_updated_cb, ImageLoaderBackendCbSize size_cb, ImageLoaderBackendCbAreaPrepared area_prepared_cb, gpointer data) -{ - ImageLoaderWEBP *loader = g_new0(ImageLoaderWEBP, 1); - loader->area_updated_cb = area_updated_cb; - loader->size_cb = size_cb; - loader->area_prepared_cb = area_prepared_cb; - loader->data = data; - return (gpointer) loader; -} - -static void image_loader_webp_set_size(gpointer loader, int width, int height) -{ - ImageLoaderWEBP *ld = (ImageLoaderWEBP *) loader; - ld->requested_width = width; - ld->requested_height = height; -} - -static GdkPixbuf* image_loader_webp_get_pixbuf(gpointer loader) -{ - ImageLoaderWEBP *ld = (ImageLoaderWEBP *) loader; - return ld->pixbuf; -} - -static gchar* image_loader_webp_get_format_name(gpointer UNUSED(loader)) -{ - return g_strdup("webp"); -} - -static gchar** image_loader_webp_get_format_mime_types(gpointer UNUSED(loader)) -{ - static gchar *mime[] = {"image/webp", NULL}; - return g_strdupv(mime); -} - -static gboolean image_loader_webp_close(gpointer UNUSED(loader), GError **UNUSED(error)) -{ - return TRUE; -} - -static void image_loader_webp_abort(gpointer loader) -{ - ImageLoaderWEBP *ld = (ImageLoaderWEBP *) loader; - ld->abort = TRUE; -} - -static void image_loader_webp_free(gpointer loader) -{ - ImageLoaderWEBP *ld = (ImageLoaderWEBP *) loader; - if (ld->pixbuf) g_object_unref(ld->pixbuf); - g_free(ld); -} - -void image_loader_backend_set_webp(ImageLoaderBackend *funcs) -{ - funcs->loader_new = image_loader_webp_new; - funcs->set_size = image_loader_webp_set_size; - funcs->load = image_loader_webp_load; - funcs->write = NULL; - funcs->get_pixbuf = image_loader_webp_get_pixbuf; - funcs->close = image_loader_webp_close; - funcs->abort = image_loader_webp_abort; - funcs->free = image_loader_webp_free; - funcs->get_format_name = image_loader_webp_get_format_name; - funcs->get_format_mime_types = image_loader_webp_get_format_mime_types; -} - -#endif -/* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */ diff --git a/src/image-load-webp.h b/src/image-load-webp.h deleted file mode 100644 index 7e4c3a93..00000000 --- a/src/image-load-webp.h +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright (C) 20019 - The Geeqie Team - * - * Author: Colin Clark - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifndef IMAGE_LOAD_WEBP_H -#define IMAGE_LOAD_WEBP_H - -#ifdef HAVE_WEBP -void image_loader_backend_set_webp(ImageLoaderBackend *funcs); -#endif - -#endif -/* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */ diff --git a/src/image-load.cc b/src/image-load.cc index 44db91e2..247ffc5d 100644 --- a/src/image-load.cc +++ b/src/image-load.cc @@ -33,7 +33,6 @@ #include "image-load-heif.h" #include "image-load-ffmpegthumbnailer.h" #include "image-load-collection.h" -#include "image-load-webp.h" #include "image-load-zxscr.h" #include "image-load-j2k.h" #include "image-load-jpegxl.h" @@ -673,16 +672,6 @@ static void image_loader_setup_loader(ImageLoader *il) } else #endif -#ifdef HAVE_WEBP - if (il->bytes_total >= 12 && - (memcmp(il->mapped_file, "RIFF", 4) == 0) && - (memcmp(il->mapped_file + 8, "WEBP", 4) == 0)) - { - DEBUG_1("Using custom webp loader"); - image_loader_backend_set_webp(&il->backend); - } - else -#endif #ifdef HAVE_DJVU if (il->bytes_total >= 16 && (memcmp(il->mapped_file, "AT&TFORM", 8) == 0) && diff --git a/src/layout-image.cc b/src/layout-image.cc index ca192829..58236361 100644 --- a/src/layout-image.cc +++ b/src/layout-image.cc @@ -347,7 +347,7 @@ static gboolean layout_image_animate_check(LayoutWindow *lw) { if (!layout_valid(&lw)) return FALSE; - if(!lw->options.animate || lw->image->image_fd == NULL || lw->image->image_fd->extension == NULL || g_ascii_strcasecmp(lw->image->image_fd->extension,".GIF")!=0) + if(!lw->options.animate || lw->image->image_fd == NULL || lw->image->image_fd->extension == NULL || (g_ascii_strcasecmp(lw->image->image_fd->extension,".GIF")!=0 && g_ascii_strcasecmp(lw->image->image_fd->extension,".WEBP")!=0)) { if(lw->animation) { @@ -453,7 +453,7 @@ static gboolean layout_image_animate_new_file(LayoutWindow *lw) } else { - log_printf("Error reading GIF file: %s\nError: %s\n", lw->image->image_fd->path, error->message); + log_printf("Error reading animation file: %s\nError: %s\n", lw->image->image_fd->path, error->message); } return TRUE; diff --git a/src/layout-util.cc b/src/layout-util.cc index 99adce0d..80b29c43 100644 --- a/src/layout-util.cc +++ b/src/layout-util.cc @@ -2632,7 +2632,7 @@ static GtkToggleActionEntry menu_toggle_entries[] = { { "ImageOverlay", NULL, N_("Image _Overlay"), NULL, N_("Image Overlay"), CB(layout_menu_overlay_cb), FALSE }, { "ImageHistogram", NULL, N_("_Show Histogram"), NULL, N_("Show Histogram"), CB(layout_menu_histogram_cb), FALSE }, { "RectangularSelection", PIXBUF_INLINE_ICON_SELECT_RECTANGLE, N_("Rectangular Selection"), "R", N_("Rectangular Selection"), CB(layout_menu_rectangular_selection_cb), FALSE }, - { "Animate", NULL, N_("GIF _animation"), "A", N_("Toggle GIF animation"), CB(layout_menu_animate_cb), FALSE }, + { "Animate", NULL, N_("_Animation"), "A", N_("Toggle animation"), CB(layout_menu_animate_cb), FALSE }, { "ExifRotate", GTK_STOCK_ORIENTATION_PORTRAIT, N_("_Exif rotate"), "X", N_("Toggle Exif rotate"), CB(layout_menu_exif_rotate_cb), FALSE }, { "DrawRectangle", PIXBUF_INLINE_ICON_DRAW_RECTANGLE, N_("Draw Rectangle"), NULL, N_("Draw Rectangle"), CB(layout_menu_select_rectangle_cb), FALSE }, { "OverUnderExposed", PIXBUF_INLINE_ICON_EXPOSURE, N_("Over/Under Exposed"), "E", N_("Highlight over/under exposed"), CB(layout_menu_select_overunderexposed_cb), FALSE }, diff --git a/src/meson.build b/src/meson.build index 83ae2fa5..8eb4c1c6 100644 --- a/src/meson.build +++ b/src/meson.build @@ -123,8 +123,6 @@ main_sources = files('advanced-exif.cc', 'image-load-svgz.h', 'image-load-tiff.cc', 'image-load-tiff.h', -'image-load-webp.cc', -'image-load-webp.h', 'image-load-zxscr.cc', 'image-load-zxscr.h', 'image-overlay.cc', @@ -286,7 +284,6 @@ libjpeg_dep, libjxl_dep, libopenjp2_dep, libraw_dep, -libwebp_dep, lua_dep, poppler_glib_dep, thread_dep,