Skip to content

Commit ebd0c23

Browse files
authored
Add support for smart object layers (#134)
1 parent 7b60827 commit ebd0c23

File tree

281 files changed

+23483
-5663
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

281 files changed

+23483
-5663
lines changed

.github/workflows/build-wheels.yml

+21-11
Original file line numberDiff line numberDiff line change
@@ -63,22 +63,31 @@ jobs:
6363
steps:
6464
- uses: actions/checkout@v4
6565
with:
66-
submodules: true
67-
68-
# We need to specify Xcode15.3 here as the default for macos-14 runners is 15.01 which has a bug
69-
# causing linking to fail.
70-
- name: Setup Xcode 15.3
71-
if: matrix.os == 'macos-latest'
72-
uses: maxim-lobanov/setup-xcode@v1
66+
submodules: 'recursive'
67+
fetch-depth: 0
68+
69+
# Further brew packages needed to run/install vcpkg dependencies
70+
- name: Setup macos dependencies
71+
if: matrix.os_dist.os == 'macos-latest'
72+
run: |
73+
brew install ninja
74+
brew install autoconf
75+
brew install libtool
76+
brew install automake
77+
78+
- name: Initialize vcpkg
79+
uses: lukka/run-vcpkg@v11
7380
with:
74-
xcode-version: '15.3'
81+
vcpkgDirectory: '${{ github.workspace }}/thirdparty/vcpkg'
7582

76-
- uses: pypa/cibuildwheel@v2.16
83+
- uses: pypa/cibuildwheel@v2.22.0
7784
env:
7885
CC: gcc-13
7986
CXX: g++-13
8087
CIBW_ARCHS: auto64
81-
CIBW_MANYLINUX_X86_64_IMAGE: manylinux_2_28
88+
MACOSX_DEPLOYMENT_TARGET: 14.0
89+
CIBW_BEFORE_BUILD: pip install cmake
90+
CIBW_MANYLINUX_X86_64_IMAGE: quay.io/pypa/manylinux_2_34_x86_64:latest
8291
CIBW_BUILD: "${{ matrix.os_dist.dist }}"
8392
# Test not only by running the test suite but also by executing every example we provide. This is to ensure
8493
# our examples are working and users can rely on them for starting off points
@@ -91,6 +100,7 @@ jobs:
91100
python -u {project}/PhotoshopExamples/ModifyLayerStructure/modify_layer_structure.py &&
92101
python -u {project}/PhotoshopExamples/ReplaceImageData/replace_image_data.py &&
93102
python -u {project}/PhotoshopExamples/RescaleCanvas/rescale_canvas.py &&
103+
python -u {project}/PhotoshopExamples/SmartObjects/smart_objects.py &&
94104
nosetests {project}/python/psapi-test --verbose
95105
96106
- name: Verify clean directory
@@ -102,7 +112,7 @@ jobs:
102112
with:
103113
name: PhotoshopAPI_Py-${{ matrix.os_dist.os }}-${{ matrix.os_dist.dist }}
104114
path: wheelhouse/*.whl
105-
115+
106116
mock-publish:
107117
name: Mock Upload release to PyPI
108118
permissions:

.github/workflows/cmake-build.yml

+29-26
Original file line numberDiff line numberDiff line change
@@ -26,60 +26,63 @@ jobs:
2626
os: ubuntu-24.04
2727
compiler: gcc-13
2828
compilercxx: g++-13
29+
cflags: ""
30+
cxxflags: ""
2931
- name: Ubuntu Clang
3032
os: ubuntu-24.04
3133
compiler: clang
3234
compilercxx: clang++
35+
cflags: ""
36+
cxxflags: ""
3337
- name: Windows MSVC
3438
os: windows-latest
3539
compiler: msvc
3640
compilercxx: msvc
41+
cflags: ""
42+
cxxflags: ""
3743
- name: MacOS ARM GCC
3844
os: macos-latest
3945
compiler: gcc-13
40-
compilercxx: g++-13
46+
compilercxx: g++-13
47+
cflags: ""
48+
cxxflags: ""
4149

4250
steps:
4351
- uses: actions/checkout@v4
4452
with:
4553
submodules: 'recursive'
46-
47-
# We need to specify Xcode15.3 here as the default for macos-14 runners is 15.01 which has a bug
48-
# causing linking to fail.
49-
- name: Setup Xcode 15.3
54+
fetch-depth: 0
55+
56+
# Further brew packages needed to run/install vcpkg dependencies
57+
- name: Setup MacOS dependencies
5058
if: matrix.os == 'macos-latest'
51-
uses: maxim-lobanov/setup-xcode@v1
59+
run: |
60+
brew install ninja
61+
brew install autoconf
62+
brew install libtool
63+
brew install automake
64+
65+
- name: Initialize vcpkg
66+
uses: lukka/run-vcpkg@v11
5267
with:
53-
xcode-version: '15.3'
68+
vcpkgDirectory: '${{ github.workspace }}/thirdparty/vcpkg'
5469

5570
- name: Configure CMake ${{ matrix.os }}-${{ matrix.compilercxx }}
5671
env:
5772
CC: ${{ matrix.compiler }}
5873
CXX: ${{ matrix.compilercxx }}
74+
CFLAGS: ${{ matrix.cflags }}
75+
CXXFLAGS: ${{ matrix.cxxflags }}
5976
run: |
60-
cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DPSAPI_BUILD_DOCS=OFF -DPSAPI_BUILD_BENCHMARKS=OFF -DPSAPI_BUILD_EXAMPLES=OFF -DPSAPI_BUILD_PYTHON=OFF
77+
cmake -B ${{github.workspace}}/build -DCMAKE_OSX_ARCHITECTURES="arm64" -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DPSAPI_BUILD_DOCS=OFF -DPSAPI_BUILD_BENCHMARKS=OFF -DPSAPI_BUILD_TESTS=OFF -DPSAPI_BUILD_EXAMPLES=ON -DPSAPI_BUILD_PYTHON=OFF
6178
6279
6380
- name: Build ${{ matrix.os }}-${{ matrix.compilercxx }}
6481
# Build your program with the given configuration
6582
env:
6683
CC: ${{ matrix.compiler }}
6784
CXX: ${{ matrix.compilercxx }}
68-
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}}
69-
70-
71-
# Call our python script to generate the relevant release artifacts after which we upload
72-
# them for each platform
73-
- name: Set up Python
74-
uses: actions/setup-python@v5
75-
with:
76-
python-version: '3.10'
77-
78-
- name: Generate artifacts for ${{ matrix.os }}-${{ matrix.compilercxx }}
79-
run: python scripts/generate_release.py --build-dir ${{github.workspace}}/build
80-
81-
- name: Upload Release Artifacts
82-
uses: actions/upload-artifact@v4
83-
with:
84-
name: PhotoshopAPI-${{ matrix.os }}-${{ matrix.compilercxx }}
85-
path: ${{github.workspace}}/release
85+
CFLAGS: ${{ matrix.cflags }}
86+
CXXFLAGS: ${{ matrix.cxxflags }}
87+
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} --parallel $(getconf _NPROCESSORS_ONLN || sysctl -n hw.ncpu || echo %NUMBER_OF_PROCESSORS%)
88+

.github/workflows/cmake-test.yml

+19-12
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,14 @@ jobs:
2626
os: ubuntu-24.04
2727
compiler: gcc-13
2828
compilercxx: g++-13
29-
cflags: ""
30-
cxxflags: ""
29+
cflags: "-fsanitize=address,leak,undefined"
30+
cxxflags: "-fsanitize=address,leak,undefined"
3131
- name: Ubuntu Clang
3232
os: ubuntu-24.04
3333
compiler: clang
34+
compilercxx: clang++
3435
cflags: "-fsanitize=address,leak,undefined"
3536
cxxflags: "-fsanitize=address,leak,undefined"
36-
compilercxx: clang++
3737
- name: Windows MSVC
3838
os: windows-latest
3939
compiler: msvc
@@ -51,31 +51,38 @@ jobs:
5151
- uses: actions/checkout@v4
5252
with:
5353
submodules: 'recursive'
54-
55-
# We need to specify Xcode15.3 here as the default for macos-14 runners is 15.01 which has a bug
56-
# causing linking to fail.
57-
- name: Setup Xcode 15.3
54+
fetch-depth: 0
55+
56+
# Further brew packages needed to run/install vcpkg dependencies
57+
- name: Setup MacOS dependencies
5858
if: matrix.os == 'macos-latest'
59-
uses: maxim-lobanov/setup-xcode@v1
60-
with:
61-
xcode-version: '15.3'
59+
run: |
60+
brew install ninja
61+
brew install autoconf
62+
brew install libtool
63+
brew install automake
6264
65+
- name: Initialize vcpkg
66+
uses: lukka/run-vcpkg@v11
67+
with:
68+
vcpkgDirectory: '${{ github.workspace }}/thirdparty/vcpkg'
69+
6370
- name: Configure CMake ${{ matrix.os }}-${{ matrix.compilercxx }}
6471
env:
6572
CC: ${{ matrix.compiler }}
6673
CXX: ${{ matrix.compilercxx }}
6774
CFLAGS: ${{ matrix.cflags }}
6875
CXXFLAGS: ${{ matrix.cxxflags }}
6976
run: |
70-
cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DPSAPI_BUILD_DOCS=OFF -DPSAPI_BUILD_BENCHMARKS=OFF -DPSAPI_BUILD_EXAMPLES=OFF -DPSAPI_BUILD_PYTHON=OFF
77+
cmake -B ${{github.workspace}}/build -DCMAKE_OSX_ARCHITECTURES="arm64" -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DPSAPI_BUILD_DOCS=OFF -DPSAPI_BUILD_BENCHMARKS=OFF -DPSAPI_BUILD_EXAMPLES=OFF -DPSAPI_BUILD_PYTHON=OFF
7178
7279
- name: Build ${{ matrix.os }}-${{ matrix.compilercxx }}
7380
env:
7481
CC: ${{ matrix.compiler }}
7582
CXX: ${{ matrix.compilercxx }}
7683
CFLAGS: ${{ matrix.cflags }}
7784
CXXFLAGS: ${{ matrix.cxxflags }}
78-
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}}
85+
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} --parallel $(getconf _NPROCESSORS_ONLN || sysctl -n hw.ncpu || echo %NUMBER_OF_PROCESSORS%)
7986

8087
# On windows we need to copy the test files differently as it generates sub-folders
8188
# for the copied test files

.github/workflows/cmake-valgrind.yml

+17-3
Original file line numberDiff line numberDiff line change
@@ -26,34 +26,48 @@ jobs:
2626
os: ubuntu-24.04
2727
compiler: gcc-13
2828
compilercxx: g++-13
29+
cflags: ""
30+
cxxflags: ""
2931
- name: Ubuntu Clang
3032
os: ubuntu-24.04
3133
compiler: clang
3234
compilercxx: clang++
35+
cflags: ""
36+
cxxflags: ""
3337

3438
steps:
3539
- uses: actions/checkout@v4
3640
with:
3741
submodules: 'recursive'
42+
fetch-depth: 0
43+
44+
- name: Load or restore vcpkg libraries
45+
uses: lukka/run-vcpkg@v11
46+
with:
47+
vcpkgDirectory: '${{ github.workspace }}/thirdparty/vcpkg'
3848

3949
- name: Configure CMake ${{ matrix.os }}-${{ matrix.compilercxx }}
4050
env:
4151
CC: ${{ matrix.compiler }}
4252
CXX: ${{ matrix.compilercxx }}
53+
CFLAGS: ${{ matrix.cflags }}
54+
CXXFLAGS: ${{ matrix.cxxflags }}
4355
run: |
44-
cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DPSAPI_BUILD_DOCS=OFF -DPSAPI_BUILD_BENCHMARKS=OFF -DPSAPI_BUILD_EXAMPLES=OFF -DPSAPI_BUILD_PYTHON=OFF
56+
cmake -B ${{github.workspace}}/build -DCMAKE_OSX_ARCHITECTURES="arm64" -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DPSAPI_BUILD_DOCS=OFF -DPSAPI_BUILD_BENCHMARKS=OFF -DPSAPI_BUILD_EXAMPLES=ON -DPSAPI_BUILD_PYTHON=OFF
4557
4658
- name: Build ${{ matrix.os }}-${{ matrix.compilercxx }}
4759
env:
4860
CC: ${{ matrix.compiler }}
4961
CXX: ${{ matrix.compilercxx }}
50-
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}}
62+
CFLAGS: ${{ matrix.cflags }}
63+
CXXFLAGS: ${{ matrix.cxxflags }}
64+
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} --parallel $(getconf _NPROCESSORS_ONLN || sysctl -n hw.ncpu || echo %NUMBER_OF_PROCESSORS%)
5165

5266
- name: Run Valgrind
5367
if: matrix.os == 'ubuntu-24.04'
5468
working-directory: ${{github.workspace}}/build/PhotoshopTest
5569
run: |
5670
sudo apt-get update
5771
sudo apt-get install -y valgrind
58-
valgrind --leak-check=full ./PhotoshopTest
72+
valgrind --leak-check=full --show-leak-kinds=all --track-origins=yes ./PhotoshopTest
5973
continue-on-error: false

.gitmodules

+6-3
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,15 @@
77
[submodule "thirdparty/pybind11"]
88
path = thirdparty/pybind11
99
url = https://github.com/pybind/pybind11
10-
[submodule "thirdparty/libdeflate"]
11-
path = thirdparty/libdeflate
12-
url = https://github.com/ebiggers/libdeflate
1310
[submodule "thirdparty/mio"]
1411
path = thirdparty/mio
1512
url = https://github.com/vimpunk/mio
1613
[submodule "thirdparty/simdutf"]
1714
path = thirdparty/simdutf
1815
url = https://github.com/simdutf/simdutf
16+
[submodule "thirdparty/vcpkg"]
17+
path = thirdparty/vcpkg
18+
url = https://github.com/microsoft/vcpkg
19+
[submodule "thirdparty/json"]
20+
path = thirdparty/json
21+
url = https://github.com/nlohmann/json

CMakeLists.txt

+34-10
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,21 @@
11
cmake_minimum_required (VERSION 3.20)
2+
set(VCPKG_LIBRARY_LINKAGE "static")
23
project ("PhotoshopAPIBuild" VERSION 0.5.2 LANGUAGES CXX)
34

45
if (MSVC)
5-
# MSVC is stupid
66
add_compile_definitions(NOMINMAX)
77
endif()
88

99
# --------------------------------------------------------------------------
1010
# Configurable options
1111

12-
option(PSAPI_BUILD_STATIC "Build a static library version of the PhotoshopAPI" ON)
12+
option(PSAPI_BUILD_STATIC "Build a static library version of the PhotoshopAPI, currently must be on as we dont create a dynamic library target" ON)
13+
option(PSAPI_USE_VCPKG "Build the extra dependencies using vckpg instead of system installed libraries" ON)
1314
option(PSAPI_BUILD_TESTS "Build the tests associated with the PhotoshopAPI" ON)
1415
option(PSAPI_BUILD_EXAMPLES "Build the examples associated with the PhotoshopAPI" ON)
1516
option(PSAPI_BUILD_BENCHMARKS "Build the benchmarks associated with the PhotoshopAPI" ON)
16-
option(PSAPI_BUILD_DOCS "Builds the documentation, requires some external installs which are documented in the README.md" OFF)
17-
option(PSAPI_BUILD_PYTHON "Build the python bindings associated with the PhotoshopAPI" OFF)
17+
option(PSAPI_BUILD_DOCS "Builds the documentation, requires some external installs which are documented in the README.md" ON)
18+
option(PSAPI_BUILD_PYTHON "Build the python bindings associated with the PhotoshopAPI" ON)
1819

1920

2021
if (PSAPI_BUILD_PYTHON)
@@ -23,6 +24,7 @@ if (PSAPI_BUILD_PYTHON)
2324
endif()
2425

2526

27+
2628
# Build setup
2729
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
2830
set (CMAKE_CXX_STANDARD 20)
@@ -32,14 +34,33 @@ set (CMAKE_CXX_STANDARD 20)
3234
set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake" ${CMAKE_MODULE_PATH})
3335

3436

35-
# Add thirdparty libraries
37+
# Set up our toolchain using the local vcpkg, gets the
3638
# --------------------------------------------------------------------------
3739

40+
# Include the local vcpkg toolchain, if specified
41+
if (PSAPI_USE_VCPKG)
42+
include("${PROJECT_SOURCE_DIR}/thirdparty/vcpkg/scripts/buildsystems/vcpkg.cmake")
43+
endif()
44+
45+
# Here we add support for OpenImageIO which is used for smart object image data extraction.
46+
find_package(OpenImageIO CONFIG REQUIRED)
47+
48+
# Add libdeflate for zip compression and decompression
49+
find_package(libdeflate CONFIG REQUIRED)
50+
51+
# Eigen is used to construct e.g. homographies for applying non-affine transforms
52+
find_package(Eigen3 CONFIG REQUIRED)
53+
54+
# fmt library for formatting and logging.
55+
find_package(fmt CONFIG REQUIRED)
3856

39-
# Add libdeflate
40-
add_subdirectory (thirdparty/libdeflate)
41-
add_library(libdeflate_include INTERFACE)
42-
target_include_directories(libdeflate_include SYSTEM INTERFACE thirdparty/libdeflate)
57+
# UUID for storing e.g. uuids of smart objects
58+
find_package(stduuid CONFIG REQUIRED)
59+
60+
61+
62+
# Add thirdparty libraries
63+
# --------------------------------------------------------------------------
4364

4465
# Add mio for memory-mapped IO files
4566
add_subdirectory (thirdparty/mio)
@@ -57,7 +78,6 @@ add_subdirectory (thirdparty/c-blosc2 EXCLUDE_FROM_ALL)
5778
add_library(blosc2_include INTERFACE)
5879
target_include_directories(blosc2_include SYSTEM INTERFACE thirdparty/c-blosc2/include)
5980

60-
6181
# Add doctest
6282
add_library(doctest INTERFACE)
6383
target_include_directories(doctest SYSTEM INTERFACE thirdparty/doctest/doctest)
@@ -68,6 +88,9 @@ set (SIMDUTF_TOOLS OFF)
6888
set (SIMDUTF_ICONV OFF)
6989
add_subdirectory (thirdparty/simdutf)
7090

91+
# JSON module for parsing of Descriptors
92+
add_subdirectory(thirdparty/json)
93+
7194
# Add span from tcb for compatibility with older compilers for python bindings
7295
add_library(tcb_span INTERFACE)
7396
target_include_directories(tcb_span SYSTEM INTERFACE thirdparty/compatibility)
@@ -92,6 +115,7 @@ if(PSAPI_BUILD_EXAMPLES)
92115
add_subdirectory (PhotoshopExamples/ModifyLayerStructure)
93116
add_subdirectory (PhotoshopExamples/ProgressCallbacks)
94117
add_subdirectory (PhotoshopExamples/ReplaceImageData)
118+
add_subdirectory (PhotoshopExamples/SmartObjects)
95119
endif()
96120
if(PSAPI_BUILD_DOCS)
97121
if(NOT PSAPI_BUILD_PYTHON)

0 commit comments

Comments
 (0)