Skip to content

Commit

Permalink
Merge pull request #628 from Kicer86/windows_build_fixes
Browse files Browse the repository at this point in the history
Update ICO generation srcipts and docs
  • Loading branch information
Kicer86 committed Apr 27, 2024
2 parents 73a6369 + 46dbda6 commit 8f2eb17
Show file tree
Hide file tree
Showing 7 changed files with 84 additions and 22 deletions.
1 change: 0 additions & 1 deletion .github/expected_file_list
Original file line number Diff line number Diff line change
Expand Up @@ -660,7 +660,6 @@ translations\qt_zh_CN.qm
translations\qt_zh_TW.qm
tr\photo_broom_en.qm
tr\photo_broom_pl.qm
Uninstall.exe
updater.dll
vcruntime140_1.dll
vcruntime140.dll
Expand Down
14 changes: 13 additions & 1 deletion .github/vcpkg_overlays/qt/qttools/vcpkg.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
{
"name": "qttools",
"version": "6.4.0",
"port-version": 0
"port-version": 0,
"default-features": [
"linguist",
"qml"
],
"features": {
"linguist": {
"description": "linguist"
},
"qml": {
"description": "qml"
}
}
}
6 changes: 5 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@

cmake_minimum_required(VERSION 3.18)
cmake_minimum_required(VERSION 3.25)
project(PhotoBroom VERSION 1.7.0 LANGUAGES CXX)

if(POLICY CMP0140)
cmake_policy(SET CMP0140 NEW)
endif()

if(POLICY CMP0146)
cmake_policy(SET CMP0146 OLD)
endif()
Expand Down
69 changes: 56 additions & 13 deletions cmake/functions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -131,42 +131,85 @@ function(stringify_file output_file input_file variable_with_type namespace)
endfunction(stringify_file)


function(convertSVG output_file input_file width height)
find_program(Magick magick)
function(determine_image_conversion_tool result)
find_program(Python python)

if(Python)
execute_process(
COMMAND ${Python} ${PROJECT_SOURCE_DIR}/tools/svg2any.py --check-requirements _ _
RESULT_VARIABLE _result
OUTPUT_QUIET
ERROR_QUIET
)

if(_result EQUAL 0) # success
set(${result} "PYTHON")
return(PROPAGATE ${result})
endif()
endif()

find_program(Magick magick)
if(Magick)
set(${result} "MAGICK")
return(PROPAGATE ${result})
endif()

set(${result} "NONE")
return(PROPAGATE ${result})
endfunction()


function(convertSVG output_file input_file width height)

if(NOT A_PB_IMAGE_CONVERTER)
determine_image_conversion_tool(converter)
set(A_PB_IMAGE_CONVERTER ${converter} CACHE INTERNAL "Tool used for converting svg files" FORCE)
endif()

if(A_PB_IMAGE_CONVERTER STREQUAL "NONE")
# Magick executable was not found OR
# Python executable was not found OR
# Python was found but there are missing dependencies for tools/svg2any.py
message(FATAL_ERROR "Neither magick nor python can be used for generation of required images.")
endif()

if(A_PB_IMAGE_CONVERTER STREQUAL "PYTHON")
find_program(Python python REQUIRED)

if(${width} EQUAL -1 AND ${height} EQUAL -1)
set(resize "")
elseif(${width} EQUAL -1 OR ${height} EQUAL -1)
message(FATAL_ERROR "Not handled")
else()
set(resize -resize ${width}x${height})
endif()

get_filename_component(output_file_ext ${output_file} EXT)
if(${output_file_ext} STREQUAL "png")
set(output_file "png32:${output_file}")
set(resize --width ${width} --height ${height})
endif()

add_custom_command(OUTPUT ${output_file}
COMMAND ${Magick} convert ${input_file} ${resize} ${output_file}
COMMAND ${Python} ${PROJECT_SOURCE_DIR}/tools/svg2any.py ${input_file} ${output_file} ${resize}
DEPENDS ${input_file}
)
else()
find_program(Python python REQUIRED)
elseif(A_PB_IMAGE_CONVERTER STREQUAL "MAGICK")
find_program(Magick magick REQUIRED)

if(${width} EQUAL -1 AND ${height} EQUAL -1)
set(resize "")
elseif(${width} EQUAL -1 OR ${height} EQUAL -1)
message(FATAL_ERROR "Not handled")
else()
set(resize --width ${width} --height ${height})
set(resize -resize ${width}x${height})
endif()

get_filename_component(output_file_ext ${output_file} EXT)
if(${output_file_ext} STREQUAL "png")
set(output_file "png32:${output_file}")
endif()

add_custom_command(OUTPUT ${output_file}
COMMAND ${Python} ${PROJECT_SOURCE_DIR}/tools/svg2any.py ${input_file} ${output_file} ${resize}
COMMAND ${Magick} convert ${input_file} ${resize} ${output_file}
DEPENDS ${input_file}
)
else()
message(FATAL_ERROR "Unexpected value of A_PB_IMAGE_CONVERTER variable: ${A_PB_IMAGE_CONVERTER}")
endif()
endfunction()

Expand Down
2 changes: 1 addition & 1 deletion docs/build.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ Required tools and libraries:
for download, build and install all marked libraries.

** Only on Windows.
Make sure PIL and cairosvg are installed.
Make sure PIL, defusedxml and cairosvg are installed.
For cairosvg to work, it may be required to install pipwin and then to install cairocffi with:
pipwin install cairocffi

Expand Down
8 changes: 4 additions & 4 deletions tools/svg2any.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ def get_svg_size(input_svg):


def svg_to_any(input_svg, output_any, desired_size):

default_width, default_height = get_svg_size(input_svg)

width = default_width if desired_size[0] == -1 else desired_size[0]
Expand All @@ -39,7 +38,7 @@ def svg_to_any(input_svg, output_any, desired_size):
img = white_background.convert('RGB')

with open(output_any, 'wb') as output_file:
img.save(output_file, sizes=[width, height])
img.save(output_file, sizes=[(width, height)])


if __name__ == "__main__":
Expand All @@ -48,7 +47,8 @@ def svg_to_any(input_svg, output_any, desired_size):
parser.add_argument("output_file", help="Output image path")
parser.add_argument("--width", type=int, default=-1, help="Output file width")
parser.add_argument("--height", type=int, default=-1, help="Output file height")
parser.add_argument("--check-requirements", action='store_true', default=False, help="Do nothing, just exit. Used for dependencies check.")

args = parser.parse_args()

svg_to_any(args.input_svg, args.output_file, (args.width, args.height))
if not args.check_requirements:
svg_to_any(args.input_svg, args.output_file, (args.width, args.height))
6 changes: 5 additions & 1 deletion vcpkg.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,11 @@
"magic-enum",
"qtbase",
"qtsvg",
"qttools",
{
"name": "qttools",
"default-features": false,
"features": [ "linguist", "qml" ]
},
"qtdeclarative",
"qtmultimedia",
"qtquick3d"
Expand Down

0 comments on commit 8f2eb17

Please sign in to comment.