c-koi / gmic-qt

G'MIC-Qt is a versatile front-end to the image processing framework G'MIC.
GNU General Public License v3.0
207 stars 54 forks source link

gimp: Add experimental support for GIMP 3 #104

Closed jtojnar closed 3 years ago

jtojnar commented 3 years ago

Fixes: #90

jtojnar commented 3 years ago

Confirmed it builds and works with both GIMP 2.10.22 and 2.99.5 (0ef5d672). (Tried applying Aurora filter on an image with a single layer.) More testing appreciated.

jtojnar commented 3 years ago

@c-koi Any chance of getting this in in?

dtschump commented 3 years ago

Yes, we are definitely interested by this. But this requires to be in a reasonable working condition. Have you been able to test a little more thoroughly to see if it works properly?

jtojnar commented 3 years ago

I now tested several more random filters and all input settings and all output settings and everything seems to work fine. But it would still be nice to get someone familiar with GMic test it or tell me if there is something specific I should check.

dtschump commented 3 years ago

I'd be happy to test. Do you know if there is any "easy" way to install GIMP 3 (on Ubuntu 20.04), or do I have to compile it by myself from scratch ?

jtojnar commented 3 years ago

It can be installed through flatpak: https://www.gimp.org/downloads/devel/

Not sure if it can be used for building plug-ins though.

Alternately, you can use Nix package manager. For example, running nix-build 'https://github.com/jtojnar/nixpkgs/archive/gimp-meson.tar.gz' -A gimp-with-plugins will get you GIMP 3 with gmic-qt built from this branch.

dtschump commented 3 years ago

Trying the nix approach. Compilation looks ok, but then : how to run the dev-version of GIMP ? I've tried a lot of different things but got only the 2.10.22 version of GIMP. I'm a total noob with nix btw :)

dtschump commented 3 years ago

Nevermind, found it!

dtschump commented 3 years ago

OK, some after a few tests, I can say it looks really cool and stable. I did tests with filters that take one or several input layers, as well as filters that generate several output layers. So far, everything's fine. @c-koi : I'm definitely in favor of accepting this PR. gmic_gimp299

c-koi commented 3 years ago

Thanks!

jtojnar commented 3 years ago

I wanted to avoid the cleaner solution using IMPORTED_TARGET since it is only available in CMake 3.6+ and we are currently targeting 3.1. But it turns out target_link_directories used in the verbose solution requires even newer CMake 3.13.

Unfortunately, Ubuntu Xenial (16.04 LTS) on CI only has CMake 3.5 so we can either revert https://github.com/c-koi/gmic-qt/commit/585ef8769c784392949a1b4c41f9ccf1f2ba590f, or switch CI to Ubuntu Bionic (18.04 LTS), which has CMake 3.10 and use the simplified linking:

--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -2,7 +2,7 @@ project(gmic-qt)

 message(STATUS "Using CMake version: ${CMAKE_VERSION}")

-cmake_minimum_required(VERSION 3.1.0 FATAL_ERROR)
+cmake_minimum_required(VERSION 3.6.0 FATAL_ERROR)
 LIST (APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/modules")
 include(FeatureSummary)
 include(FindPkgConfig)
@@ -525,19 +525,17 @@ if (${GMIC_QT_HOST} STREQUAL "gimp" OR ${GMIC_QT_HOST} STREQUAL "gimp3")
     endif()

     find_package(PkgConfig REQUIRED)
-    pkg_check_modules(GIMP REQUIRED gimp-${TARGET_GIMP_VERSION}.0)
+    pkg_check_modules(GIMP REQUIRED gimp-${TARGET_GIMP_VERSION}.0 IMPORTED_TARGET)
     # CMake does not support passing --define-variable through pkg_get_variable.
     execute_process(COMMAND ${PKG_CONFIG_EXECUTABLE} gimp-${TARGET_GIMP_VERSION}.0 --define-variable=prefix=${CMAKE_INSTALL_PREFIX} --variable gimplibdir OUTPUT_VARIABLE GIMP_PKGLIBDIR OUTPUT_STRIP_TRAILING_WHITESPACE)

     set (gmic_qt_SRCS ${gmic_qt_SRCS} src/Host/Gimp/host_gimp.cpp)
     add_definitions(-DGMIC_HOST=gimp -DGIMP_DISABLE_DEPRECATED)
     add_executable(gmic_gimp_qt ${gmic_qt_SRCS} ${gmic_qt_QRC} ${qmic_qt_QM})
-    target_include_directories(gmic_gimp_qt PRIVATE ${GIMP_INCLUDE_DIRS})
-    target_link_directories(gmic_gimp_qt PRIVATE ${GIMP_LIBRARY_DIRS})
     target_link_libraries(
       gmic_gimp_qt
       PRIVATE
-      ${GIMP_LIBRARIES}
+      PkgConfig::GIMP
       ${gmic_qt_LIBRARIES}
       )
     install(TARGETS gmic_gimp_qt RUNTIME DESTINATION "${GIMP_PKGLIBDIR}/plug-ins/gmic_gimp_qt")

It should not be much of a problem since Xenial has EOL in April.

dtschump commented 3 years ago
jtojnar commented 3 years ago

Okay, opened https://github.com/c-koi/gmic-qt/pull/106 to fix the CI.

chris-morgan commented 3 years ago

As someone just trying this out now (via patching the AUR gimp-plugin-gmic-git package to use the directory /usr/lib/gimp/2.99/plug-ins/gmic_gimp_qt/ instead of /usr/lib/gimp/2.0/plug-ins/, and to pass HOST=gimp3 instead of HOST=gimp), I was confused to find this failing to link, with ApplicationName and ApplicationShortname undefined. Turned out the reason for that was I was using the QMake build process, but this PR only covered building with CMake. Dunno if that’s significant or not, or if one is on the way out in favour of the other, but I figured I’d at least mention it here so it’s recorded.

(Subsequent to that I got compiler errors on activeLayerID >= 0 and active_layer_id >= 0 comparisons in host_gimp.cpp, #114 is a patch that at least makes it build, whether it’s correct or not.)

jtojnar commented 3 years ago

The latest GIMP version updates the plug-in API:

https://www.gimp.org/news/2021/05/08/gimp-2-99-6-released/

That is likely responsible for the build failures.

I did not bother with qmake since it has been a PITA IME.