mirror of
https://github.com/audacity/linuxdeploy.git
synced 2025-12-12 15:44:26 -06:00
Replace ImageMagick with CImg
For now, it is known to support JPEG and PNG files. Fixes #3.
This commit is contained in:
parent
ce4abed0fa
commit
76d27a352c
@ -7,8 +7,7 @@ addons:
|
||||
packages:
|
||||
- libboost-regex1.55-dev
|
||||
- libboost-filesystem1.55-dev
|
||||
- libmagick++-dev
|
||||
- libmagic-dev
|
||||
- cimg-dev
|
||||
- automake # required for patchelf
|
||||
|
||||
install:
|
||||
|
||||
22
cmake/Modules/FindCImg.cmake
Normal file
22
cmake/Modules/FindCImg.cmake
Normal file
@ -0,0 +1,22 @@
|
||||
# required for PNG imported target
|
||||
cmake_minimum_required(VERSION 3.5)
|
||||
|
||||
message(STATUS "Searching for CImg")
|
||||
|
||||
find_path(CIMG_H_DIR
|
||||
NAMES CImg.h
|
||||
HINTS ${CMAKE_INSTALL_PREFIX}
|
||||
PATH_SUFFIXES include include/linux
|
||||
)
|
||||
|
||||
if(NOT CIMG_H_DIR)
|
||||
message(FATAL_ERROR "CImg.h not found")
|
||||
endif()
|
||||
|
||||
find_package(PNG REQUIRED)
|
||||
find_package(JPEG REQUIRED)
|
||||
|
||||
add_library(CImg INTERFACE IMPORTED)
|
||||
set_property(TARGET CImg PROPERTY INTERFACE_INCLUDE_DIRECTORIES "${CIMG_H_DIR};${JPEG_INCLUDE_DIR}")
|
||||
set_property(TARGET CImg PROPERTY INTERFACE_LINK_LIBRARIES "PNG::PNG;${JPEG_LIBRARIES}")
|
||||
set_property(TARGET CImg PROPERTY INTERFACE_COMPILE_DEFINITIONS "cimg_display=0;cimg_use_png=1;cimg_use_jpeg=1")
|
||||
@ -7,10 +7,9 @@ file(GLOB HEADERS ${PROJECT_SOURCE_DIR}/include/linuxdeploy/core/*.h)
|
||||
|
||||
find_package(Threads)
|
||||
|
||||
find_package(LibMagic)
|
||||
find_package(LibMagic REQUIRED)
|
||||
|
||||
find_package(PkgConfig)
|
||||
pkg_check_modules(magick++ REQUIRED IMPORTED_TARGET Magick++)
|
||||
find_package(CImg REQUIRED)
|
||||
|
||||
message(STATUS "Generating excludelist")
|
||||
execute_process(
|
||||
@ -19,7 +18,7 @@ execute_process(
|
||||
)
|
||||
|
||||
add_library(linuxdeploy_core STATIC elf.cpp log.cpp appdir.cpp desktopfile.cpp ${HEADERS})
|
||||
target_link_libraries(linuxdeploy_core PUBLIC linuxdeploy_plugin linuxdeploy_util ${BOOST_LIBS} subprocess cpp-feather-ini-parser PkgConfig::magick++ libmagic_static ${CMAKE_THREAD_LIBS_INIT})
|
||||
target_link_libraries(linuxdeploy_core PUBLIC linuxdeploy_plugin linuxdeploy_util ${BOOST_LIBS} subprocess cpp-feather-ini-parser CImg libmagic_static ${CMAKE_THREAD_LIBS_INIT})
|
||||
target_include_directories(linuxdeploy_core PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
|
||||
target_include_directories(linuxdeploy_core PUBLIC ${PROJECT_SOURCE_DIR}/include)
|
||||
target_compile_definitions(linuxdeploy_core PUBLIC -DBOOST_NO_CXX11_SCOPED_ENUMS)
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
|
||||
// library headers
|
||||
#include <boost/filesystem.hpp>
|
||||
#include <Magick++.h>
|
||||
#include <CImg.h>
|
||||
#include <fnmatch.h>
|
||||
#include <subprocess.hpp>
|
||||
|
||||
@ -19,6 +19,7 @@
|
||||
using namespace linuxdeploy::core;
|
||||
using namespace linuxdeploy::core::log;
|
||||
|
||||
using namespace cimg_library;
|
||||
namespace bf = boost::filesystem;
|
||||
|
||||
namespace linuxdeploy {
|
||||
@ -340,17 +341,11 @@ namespace linuxdeploy {
|
||||
if (util::strLower(path.filename().extension().string()) == ".svg") {
|
||||
resolution = "scalable";
|
||||
} else {
|
||||
Magick::Image image;
|
||||
|
||||
try {
|
||||
image.read(path.string());
|
||||
} catch (const Magick::Exception& e) {
|
||||
ldLog() << LD_ERROR << "Magick error: " << e.what() << std::endl;
|
||||
return false;
|
||||
}
|
||||
CImg<unsigned char> image(path.c_str());
|
||||
|
||||
auto xRes = image.columns();
|
||||
auto yRes = image.rows();
|
||||
auto xRes = image.width();
|
||||
auto yRes = image.height();
|
||||
|
||||
if (xRes != yRes) {
|
||||
ldLog() << LD_WARNING << "x and y resolution of icon are not equal:" << path;
|
||||
@ -380,6 +375,10 @@ namespace linuxdeploy {
|
||||
ldLog() << LD_ERROR << "Icon" << path << "has invalid x resolution:" << xRes;
|
||||
return false;
|
||||
}
|
||||
} catch (const CImgException& e) {
|
||||
ldLog() << LD_ERROR << "CImg error: " << e.what() << std::endl;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// rename files like <appname>_*.ext to <appname>.ext
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user