### Test G'MIC CLI Installation (Stdlib Commands) Source: https://github.com/greyclab/gmic/blob/master/html/download.html Tests the G'MIC CLI installation by scanning all stdlib commands and generating corresponding images. This command requires the G'MIC CLI to be installed and accessible in the PATH. ```bash mkdir -p testing && cd testing gmic it https://gmic.eu/gmic_stdlib.\$_version parse_cli images ``` -------------------------------- ### Build and Install GMIC Static Library Source: https://github.com/greyclab/gmic/blob/master/CMakeLists.txt Configures and installs the GMIC static library if BUILD_LIB_STATIC is enabled. Sets the output name. ```cmake if(BUILD_LIB_STATIC) add_library(libgmicstatic STATIC ${GMIC_LIB_SOURCES}) target_compile_options(libgmicstatic PRIVATE ${GMIC_CXX_COMPILE_FLAGS} -Dgmic_core) set_target_properties(libgmicstatic PROPERTIES OUTPUT_NAME "gmic") target_link_libraries(libgmicstatic PRIVATE CImg::CImg GMicStdlib::Stdlib ) target_include_directories(libgmicstatic PUBLIC $ $ ) gmic_apply_common_deps(libgmicstatic) install(TARGETS libgmicstatic EXPORT GmicTargets ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}") endif() ``` -------------------------------- ### Install Required Packages (MSYS2) Source: https://github.com/greyclab/gmic/blob/master/html/download.html Installs essential packages for G'MIC compilation using MSYS2's pacman package manager. This command installs Qt5, GIMP development files, pkgconf, GCC, FFTW, make, and git. ```bash pacman -Sy mingw64/mingw-w64-x86_64-qt5 mingw64/mingw-w64-x86_64-gimp mingw64/mingw-w64-x86_64-pkgconf mingw64/mingw-w64-x86_64-gcc mingw64/mingw-w64-x86_64-fftw make git ``` -------------------------------- ### Test G'MIC CLI Installation (GUI Filters) Source: https://github.com/greyclab/gmic/blob/master/html/download.html Tests the G'MIC CLI installation by scanning G'MIC-Qt filters and generating corresponding images. This command requires the G'MIC CLI to be installed and accessible in the PATH. ```bash gmic it https://gmic.eu/gmic_stdlib.\$_version parse_gui images ``` -------------------------------- ### Install G'MIC Dependencies on Debian/Ubuntu Source: https://github.com/greyclab/gmic/blob/master/html/download.html Installs necessary packages for compiling G'MIC on Debian-based systems. ```bash sudo apt install git build-essential libgimp2.0-dev libcurl4-openssl-dev libfftw3-dev libtiff-dev libjpeg-dev libopenexr-dev libwebp-dev qtbase5-dev qttools5-dev-tools ``` -------------------------------- ### Build and Install GMIC Shared Library Source: https://github.com/greyclab/gmic/blob/master/CMakeLists.txt Configures and installs the GMIC shared library if BUILD_LIB is enabled. Includes setting SOVERSION and output name. ```cmake if(BUILD_LIB) add_library(libgmic SHARED ${GMIC_LIB_SOURCES}) target_compile_options(libgmic PRIVATE ${GMIC_CXX_COMPILE_FLAGS} -Dgmic_core) set_target_properties(libgmic PROPERTIES SOVERSION "1" OUTPUT_NAME "gmic") target_link_libraries(libgmic PRIVATE CImg::CImg GMicStdlib::Stdlib ) target_include_directories(libgmic PUBLIC $ $ ) gmic_apply_common_deps(libgmic) install(TARGETS libgmic EXPORT GmicTargets PUBLIC_HEADER DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}" LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" ) endif() ``` -------------------------------- ### Mixed CImg and libgmic Usage Source: https://github.com/greyclab/gmic/blob/master/html/libgmic.html This example demonstrates the integration of CImg and libgmic. It loads images using CImg, processes them with a G'MIC pipeline via libgmic, and displays the result using CImg. ```cpp //----- File 'foo3.cpp' ----- #include "CImg.h" #include "gmic.h" using namespace cimg_library; int main() { // Load input image files, using the CImg Library. CImg img1("img/lena.jpg"), img2("img/joconde.jpg"); // Move input images into a list. CImgList image_list; img1.move_to(image_list); img2.move_to(image_list); // Define the corresponding image names. CImgList image_names; CImg::string("First image").move_to(image_names); CImg::string("Second image").move_to(image_names); // Invoke libgmic to execute a G'MIC pipeline. gmic("water[0] 15 wave[1] 15 \ 320,256 mandelbrot. -0.6918,-0.4831,-0.6375,-0.4338,256 \ 64,1,1,3,?(255) r. 256,1,1,3,3 point. 0 map.. . rm. \ frame 2,2,0 to_rgba drop_shadow 3,3 montage X \ i[0] 100%,100%,1,3,255 blend alpha \ name \"Result image\"", image_list,image_names); // Display resulting image. const char *const title_bar = image_names[0]; image_list.display(title_bar); return 0; ``` -------------------------------- ### Install GMIC Header File Source: https://github.com/greyclab/gmic/blob/master/CMakeLists.txt Installs the main GMIC header file if either the shared or static library is being built. ```cmake if(BUILD_LIB OR BUILD_LIB_STATIC) install(FILES src/gmic.h DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}") endif() ``` -------------------------------- ### Build and Install GMIC CLI Executable Source: https://github.com/greyclab/gmic/blob/master/CMakeLists.txt Configures and installs the GMIC command-line interface executable if BUILD_CLI is enabled. Includes dynamic linking logic and stripping the binary. ```cmake if(BUILD_CLI) if(NOT ENABLE_DYNAMIC_LINKING AND NOT BUILD_LIB_STATIC) message(FATAL_ERROR "BUILD_CLI requires either BUILD_LIB_STATIC=ON or ENABLE_DYNAMIC_LINKING=ON") endif() add_executable(gmic src/gmic_cli.cpp) target_compile_options(gmic PRIVATE ${GMIC_CXX_COMPILE_FLAGS}) if(ENABLE_DYNAMIC_LINKING) target_link_libraries(gmic PUBLIC libgmic PRIVATE CImg::CImg ) else() target_link_libraries(gmic PRIVATE libgmicstatic) endif() gmic_apply_common_deps(gmic) if(NOT ${CMAKE_BUILD_TYPE_LOWER} STREQUAL "debug") find_program(STRIP_TOOL strip) if(STRIP_TOOL) add_custom_command(TARGET gmic POST_BUILD COMMAND ${STRIP_TOOL} $ COMMENT "Stripping gmic binary (like 'strip gmic' in the Makefile)" ) endif() endif() install(TARGETS gmic RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" ) endif() ``` -------------------------------- ### Configure and Install Gmic Package Source: https://github.com/greyclab/gmic/blob/master/CMakeLists.txt Sets up the Gmic package configuration file and installs targets. This is typically used in the main CMakeLists.txt to prepare the project for packaging and distribution. ```cmake include(CMakePackageConfigHelpers) file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/GmicConfig.cmake.in" "@PACKAGE_INIT@\ninclude(\"${CMAKE_CURRENT_LIST_DIR}/GmicTargets.cmake\")\n") configure_package_config_file( ${CMAKE_CURRENT_BINARY_DIR}/GmicConfig.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/GmicConfig.cmake INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/gmic ) install(EXPORT GmicTargets DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/gmic) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/GmicConfig.cmake DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/gmic) ``` -------------------------------- ### Setting Input Image Names Source: https://github.com/greyclab/gmic/blob/master/html/libgmic.html Input images can be assigned names, which can be useful if G'MIC commands specifically utilize these names. This example demonstrates how to set two input image names. ```cpp const char *const name1 = "First image", *const name2 = "Second image"; gmic_list image_names; image_names.assign(2); image_names[0].assign(std::strlen(name1)+1); // We don't forget the '\0'. std::strcpy(image_names[0],name1); image_names[1].assign(std::strlen(name2)+1); // We don't forget the '\0'. std::strcpy(image_names[1],name2); ``` -------------------------------- ### Generate and Install Man Page Source: https://github.com/greyclab/gmic/blob/master/CMakeLists.txt Generates the gmic man page if BUILD_MAN is enabled. It uses the gmic executable to reference its own documentation. ```cmake if(BUILD_MAN) file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/man) add_custom_command( OUTPUT ${CMAKE_BINARY_DIR}/man/gmic.1 DEPENDS gmic COMMAND ${CMAKE_COMMAND} -E env "LD_LIBRARY_PATH=${GMIC_BINARIES_PATH}" "DYLD_LIBRARY_PATH=${GMIC_BINARIES_PATH}" ${GMIC_BINARIES_PATH}/gmic ${CMAKE_SOURCE_DIR}/src/gmic_stdlib.gmic it ${CMAKE_SOURCE_DIR}/src/gmic_stdlib.gmic reference man > ${CMAKE_BINARY_DIR}/man/gmic.1 ) add_custom_target(man ALL DEPENDS ${CMAKE_BINARY_DIR}/man/gmic.1) install(FILES ${CMAKE_BINARY_DIR}/man/gmic.1 DESTINATION ${CMAKE_INSTALL_MANDIR}/man1/) endif() ``` -------------------------------- ### Generate and Install Bash Completion Script Source: https://github.com/greyclab/gmic/blob/master/CMakeLists.txt Generates the gmic bash completion script if BUILD_BASH_COMPLETION is enabled. It uses the gmic executable to parse CLI arguments for bash completion. ```cmake if(BUILD_BASH_COMPLETION) file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/resources) add_custom_command( OUTPUT ${CMAKE_BINARY_DIR}/resources/gmic_bashcompletion.sh DEPENDS gmic COMMAND ${CMAKE_COMMAND} -E env "LD_LIBRARY_PATH=${GMIC_BINARIES_PATH}" "DYLD_LIBRARY_PATH=${GMIC_BINARIES_PATH}" ${GMIC_BINARIES_PATH}/gmic ${CMAKE_SOURCE_DIR}/src/gmic_stdlib.gmic it ${CMAKE_SOURCE_DIR}/src/gmic_stdlib.gmic parse_cli bashcompletion > ${CMAKE_BINARY_DIR}/resources/gmic_bashcompletion.sh ) add_custom_target(bashcompletion ALL DEPENDS ${CMAKE_BINARY_DIR}/resources/gmic_bashcompletion.sh) install(FILES ${CMAKE_BINARY_DIR}/resources/gmic_bashcompletion.sh DESTINATION ${CMAKE_INSTALL_DATADIR}/bash-completion/completions RENAME gmic ) endif() ``` -------------------------------- ### G'MIC Image Dimensions Source: https://github.com/greyclab/gmic/blob/master/html/libgmic.html A gmic_image instance has 4 dimensions: width, height, depth, and spectrum. There are no hard limits on dimension size beyond available memory. This example illustrates the memory layout for a 2x2x1x3 RGB color image. ```text R(0,0),R(1,0),R(0,1),R(1,1),G(0,0),G(1,0),G(0,1),G(1,1),B(0,0),B(1,0),B(0,1),B(1,1) ``` -------------------------------- ### Initialize and Process Images with libgmic Source: https://github.com/greyclab/gmic/blob/master/html/libgmic.html Demonstrates constructing a list of images, assigning dimensions, filling pixel data with mathematical functions, and applying a G'MIC pipeline. Includes error handling for G'MIC exceptions. ```cpp #include "gmic.h" #include #include int main() { gmic_list image_list; image_list.assign(2); // Tell 'image_list' it has 2 images. for (unsigned int i = 0; i& img = image_list[i]; img.assign(320,200,1,3); // Fill image buffer with random sinus waves. float *ptr = img; for (unsigned int c = 0; c image_names; // We don't care about image names here, let this empty. try { gmic("water[0] 20 flower[1] 20 blend vividlight", image_list,image_names); } catch (gmic_exception &e) { // In case something went wrong. std::fprintf(stderr,"ERROR : %s\n",e.what()); return -1; } // Here, 'image_list' now contains only 1 (color) image of size 320x200x1x3. // You can retrieve the image data from the buffer at 'image_list[0]._data', // as well as the image dimensions 'image_list[0]._xxxx', where // 'xxxx' can be 'width', 'height', 'depth' or 'spectrum'. (...) // Do whatever you want with the image data here. image_list.assign(0); // Deallocate images, if you want to do it before the destructor. return 0; } ``` -------------------------------- ### Generate G'MIC-Qt Plugin Makefile (Paint.NET) Source: https://github.com/greyclab/gmic/blob/master/html/download.html Generates the Makefile for the G'MIC-Qt plugin for Paint.NET by invoking qmake with the 'HOST=paintdotnet' argument. ```bash qmake HOST=paintdotnet ``` -------------------------------- ### Generate G'MIC-Qt Plugin Makefile (GIMP) Source: https://github.com/greyclab/gmic/blob/master/html/download.html Generates the Makefile for the G'MIC-Qt plugin for GIMP by invoking qmake with the 'HOST=gimp' argument. ```bash qmake HOST=gimp ``` -------------------------------- ### Generate G'MIC-Qt Makefile Source: https://github.com/greyclab/gmic/blob/master/html/download.html Generates the Makefile for the G'MIC-Qt interface using qmake. The 'HOST=none' argument is used for a standard standalone build. ```bash qmake HOST=none ``` -------------------------------- ### Copy G'MIC-Qt Dependencies Source: https://github.com/greyclab/gmic/blob/master/html/download.html Copies essential DLL files and Qt platform plugins from the MinGW bin and share directories to the G'MIC-Qt executable's directory. This ensures the Qt interface has access to its runtime dependencies and platform support. ```bash cd /mingw64/bin/ && cp libgcc_s_seh-1.dll libwinpthread-1.dll libgomp-1.dll libstdc++-6.dll libcurl-4.dll libbrotlidec.dll libbrotlicommon.dll libcrypto-1_1-x64.dll libidn2-0.dll libiconv-2.dll libintl-8.dll libunistring-2.dll libnghttp2-14.dll libpsl-5.dll libssh2-1.dll zlib1.dll libssl-1_1-x64.dll libzstd.dll libfftw3-3.dll libpng16-16.dll Qt5Core.dll libdouble-conversion.dll libicuin67.dll libicuuc67.dll libicudt67.dll libpcre2-16-0.dll Qt5Gui.dll libharfbuzz-0.dll libgraphite2.dll libfreetype-6.dll libbz2-1.dll libglib-2.0-0.dll libpcre-1.dll Qt5Network.dll Qt5Widgets.dll PATH_TO_EXE/ ``` ```bash cp -rf /mingw64/share/qt5/plugins/platforms PATH_TO_EXE/ ``` -------------------------------- ### Test G'MIC Functionality (GUI) Source: https://github.com/greyclab/gmic/blob/master/README.md Execute all available G'MIC commands and filters, simulating GUI interaction. It's recommended to run this in a new, empty folder due to the number of files generated. ```bash $ gmic input_text https://gmic.eu/gmic_stdlib.$_version parse_gui images ``` -------------------------------- ### Compile G'MIC Interfaces Source: https://github.com/greyclab/gmic/blob/master/html/download.html Compiles specific G'MIC interfaces. Use 'make all' to compile all available interfaces. ```bash make cli # Compile command-line interface ``` ```bash make gimp # Compile plug-in for GIMP ``` ```bash make lib # Compile G'MIC library files ``` ```bash make zart # Compile ZArt ``` ```bash make all # Compile all of the G'MIC interfaces ``` -------------------------------- ### Managing G'MIC Instances Source: https://github.com/greyclab/gmic/blob/master/html/libgmic.html Instead of constructing a temporary gmic instance for each pipeline, a permanent instance can be created and reused for multiple operations. This approach is more efficient for sequential G'MIC commands. ```cpp gmic g_instance; g_instance.run("water[0] 20",image_list,image_names); g_instance.run("flower[1] 20",image_list,image_names); g_instance.run("blend vividlight",image_list,image_names); g_instance.run("output gmic_test.png",image_list,image_names); ``` -------------------------------- ### Basic libgmic Usage in C++ Source: https://github.com/greyclab/gmic/blob/master/html/libgmic.html This snippet demonstrates the basic integration of libgmic into a C++ program. It includes necessary headers, a try-catch block for error handling, and a call to the gmic function to execute a G'MIC script. ```cpp #include "gmic.h" #include int main() { try { gmic("testimage2d 512 output gmic_test.png"); } catch (gmic_exception& e) { // In case something went wrong: std::fprintf(stderr,"ERROR : %s\n",e.what()); return -1; } return 0; } ``` -------------------------------- ### Download and Extract G'MIC Source Source: https://github.com/greyclab/gmic/blob/master/html/download.html Downloads the G'MIC source archive and extracts it to the current directory. ```bash wget [https://gmic.eu/files/source/gmic_3.7.6.tar.gz](get_file.php?file=source/gmic_3.7.6.tar.gz) && tar zxvf gmic_3.7.6.tar.gz && cd gmic-3.7.6/src ``` -------------------------------- ### Compile G'MIC-Qt Source: https://github.com/greyclab/gmic/blob/master/html/download.html Compiles the G'MIC-Qt interface using the generated Makefile. The '-j4' flag enables parallel compilation using 4 threads for faster build times. ```bash make -j4 release ``` -------------------------------- ### Download and Extract G'MIC Source Source: https://github.com/greyclab/gmic/blob/master/html/download.html Downloads the G'MIC source code archive and extracts it. After extraction, it changes the directory into the extracted source folder. ```bash wget [https://gmic.eu/files/source/gmic_3.7.6.tar.gz](get_file.php?file=source/gmic_3.7.6.tar.gz) && tar zxvf gmic_3.7.6.tar.gz && cd gmic-3.7.6 ``` -------------------------------- ### Test G'MIC Functionality (CLI) Source: https://github.com/greyclab/gmic/blob/master/README.md Execute all available G'MIC commands and filters using the command-line interface. Ensure you run this in an empty folder as it generates many image files. ```bash $ gmic input_text https://gmic.eu/gmic_stdlib.$_version parse_cli images ``` -------------------------------- ### Executing a libgmic Program Source: https://github.com/greyclab/gmic/blob/master/html/libgmic.html This command demonstrates how to execute a compiled C++ program that utilizes libgmic. ```bash ./foo ``` -------------------------------- ### Summarize Project Features Source: https://github.com/greyclab/gmic/blob/master/CMakeLists.txt Generates a summary of all enabled features in the project. This command is useful for providing an overview of the project's capabilities. ```cmake feature_summary(WHAT ALL) ``` -------------------------------- ### Compiling a libgmic C++ Program Source: https://github.com/greyclab/gmic/blob/master/html/libgmic.html This command shows how to compile a C++ source file that uses the libgmic library. It links the g++ compiler with the libgmic library. ```bash g++ -o foo foo.cpp -lgmic ``` -------------------------------- ### Copy G'MIC CLI Dependencies Source: https://github.com/greyclab/gmic/blob/master/html/download.html Copies essential DLL files from the MinGW bin directory to the specified path for the G'MIC CLI executable. This ensures the executable has access to its runtime dependencies. ```bash cd /mingw64/bin/ && cp libgcc_s_seh-1.dll libwinpthread-1.dll libgomp-1.dll libstdc++-6.dll libcurl-4.dll libbrotlidec.dll libbrotlicommon.dll libcrypto-1_1-x64.dll libidn2-0.dll libiconv-2.dll libintl-8.dll libunistring-2.dll libnghttp2-14.dll libpsl-5.dll libssh2-1.dll zlib1.dll libssl-1_1-x64.dll libzstd.dll libfftw3-3.dll libjpeg-8.dll libpng16-16.dll libtiff-5.dll liblzma-5.dll PATH_TO_EXE/ ``` -------------------------------- ### Compile G'MIC CLI Source: https://github.com/greyclab/gmic/blob/master/html/download.html Compiles the G'MIC command-line interface (CLI) using the provided Makefile. The 'cli' target is specified for building the executable. ```bash make cli ``` -------------------------------- ### Add MinGW Bin to PATH Source: https://github.com/greyclab/gmic/blob/master/html/download.html Appends the MinGW-64 bin directory to the system's PATH environment variable by modifying the .bash_profile file. This ensures that compiled executables and their dependencies can be found. ```bash PATH="/mingw64/bin:${PATH}" ``` -------------------------------- ### Compile G'MIC with OpenMP Disabled Source: https://github.com/greyclab/gmic/blob/master/html/download.html Workaround for compilation issues with older g++ versions by disabling OpenMP support. ```bash make OPENMP_CFLAGS="" OPENMP_LIBS="" ``` -------------------------------- ### Conditional Build Checks for Man and Bash Completion Source: https://github.com/greyclab/gmic/blob/master/CMakeLists.txt Ensures that the CLI is enabled if man pages or bash completion are requested. ```cmake if(BUILD_MAN OR BUILD_BASH_COMPLETION) if(NOT BUILD_CLI) message(FATAL_ERROR "BUILD_MAN and BUILD_BASH_COMPLETION require BUILD_CLI=ON") endif() endif() ``` -------------------------------- ### Apply Common Dependencies to Target Source: https://github.com/greyclab/gmic/blob/master/CMakeLists.txt A CMake function to link common libraries and set compile options for a target. It handles ZLIB, OpenMP, optional libraries, compile flags, and include directories. ```cmake function(gmic_apply_common_deps target_name) target_link_libraries(${target_name} PRIVATE ZLIB::ZLIB) if(OpenMP_CXX_FOUND) target_link_libraries(${target_name} PRIVATE OpenMP::OpenMP_CXX) endif() if(GMIC_OPTIONAL_LIBS) target_link_libraries(${target_name} PRIVATE ${GMIC_OPTIONAL_LIBS}) endif() if(GMIC_OPTIONAL_COMPILE_FLAGS) target_compile_options(${target_name} PRIVATE ${GMIC_OPTIONAL_COMPILE_FLAGS}) endif() if(GMIC_OPTIONAL_INCLUDE_DIRS) target_include_directories(${target_name} PRIVATE ${GMIC_OPTIONAL_INCLUDE_DIRS}) endif() endfunction() ``` -------------------------------- ### Define GMIC Library Sources Source: https://github.com/greyclab/gmic/blob/master/CMakeLists.txt Sets the source files for the GMIC shared library. ```cmake set(GMIC_LIB_SOURCES src/gmic.cpp) ``` -------------------------------- ### Retrieving Output Image Name Source: https://github.com/greyclab/gmic/blob/master/html/libgmic.html After processing, the name of the resulting image can be retrieved from the image_names list. This assumes the G'MIC pipeline has assigned a name to the output. ```cpp const char *const output_name = image_names[0]; ``` -------------------------------- ### Compile G'MIC CLI without LTO Source: https://github.com/greyclab/gmic/blob/master/html/download.html Compiles the G'MIC CLI while disabling Link-Time Optimization (LTO) by setting the FLTO variable to an empty string. This can reduce memory usage during compilation. ```bash make FLTO="" cli ``` -------------------------------- ### G'MIC JOSS Article Citation Source: https://github.com/greyclab/gmic/blob/master/README.md BibTeX entry for citing the G'MIC JOSS article. Include this in your LaTeX documents for proper academic referencing. ```bibtex @article{Tschumperlé2025, doi = {10.21105/joss.06618}, url = {https://doi.org/10.21105/joss.06618}, year = {2025}, publisher = {The Open Journal}, volume = {10}, number = {105}, pages = {6618}, author = {David Tschumperlé and Sébastien Fourey and Garry Osgood}, title = {G'MIC: An Open-Source Self-Extending Framework for Image Processing}, journal = {Journal of Open Source Software} } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.