pylibheif 1.21.2.post2__cp314-cp314-macosx_14_0_arm64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of pylibheif might be problematic. Click here for more details.

Files changed (44) hide show
  1. include/libheif/heif.h +41 -0
  2. include/libheif/heif_aux_images.h +182 -0
  3. include/libheif/heif_brands.h +376 -0
  4. include/libheif/heif_color.h +363 -0
  5. include/libheif/heif_context.h +329 -0
  6. include/libheif/heif_cxx.h +1390 -0
  7. include/libheif/heif_decoding.h +172 -0
  8. include/libheif/heif_encoding.h +395 -0
  9. include/libheif/heif_entity_groups.h +60 -0
  10. include/libheif/heif_error.h +304 -0
  11. include/libheif/heif_image.h +355 -0
  12. include/libheif/heif_image_handle.h +129 -0
  13. include/libheif/heif_items.h +260 -0
  14. include/libheif/heif_library.h +219 -0
  15. include/libheif/heif_metadata.h +136 -0
  16. include/libheif/heif_plugin.h +378 -0
  17. include/libheif/heif_properties.h +235 -0
  18. include/libheif/heif_regions.h +868 -0
  19. include/libheif/heif_security.h +107 -0
  20. include/libheif/heif_sequences.h +644 -0
  21. include/libheif/heif_tai_timestamps.h +202 -0
  22. include/libheif/heif_text.h +161 -0
  23. include/libheif/heif_tiling.h +137 -0
  24. include/libheif/heif_uncompressed.h +109 -0
  25. include/libheif/heif_version.h +38 -0
  26. lib/cmake/libheif/libheif-config-release.cmake +19 -0
  27. lib/cmake/libheif/libheif-config-version.cmake +83 -0
  28. lib/cmake/libheif/libheif-config.cmake +108 -0
  29. lib/libheif.a +0 -0
  30. lib/pkgconfig/libheif.pc +15 -0
  31. pylibheif-1.21.2.post2.dist-info/METADATA +405 -0
  32. pylibheif-1.21.2.post2.dist-info/RECORD +44 -0
  33. pylibheif-1.21.2.post2.dist-info/WHEEL +6 -0
  34. pylibheif-1.21.2.post2.dist-info/licenses/LICENSE +165 -0
  35. pylibheif.cpython-314-darwin.so +0 -0
  36. pylibheif.dylibs/libaom.3.13.1.dylib +0 -0
  37. pylibheif.dylibs/libdav1d.7.dylib +0 -0
  38. pylibheif.dylibs/libde265.0.dylib +0 -0
  39. pylibheif.dylibs/libjpeg.8.3.2.dylib +0 -0
  40. pylibheif.dylibs/libopenh264.2.6.0.dylib +0 -0
  41. pylibheif.dylibs/libopenjp2.2.5.4.dylib +0 -0
  42. pylibheif.dylibs/libvmaf.3.dylib +0 -0
  43. pylibheif.dylibs/libx264.165.dylib +0 -0
  44. pylibheif.dylibs/libx265.215.dylib +0 -0
@@ -0,0 +1,83 @@
1
+ # This is a basic version file for the Config-mode of find_package().
2
+ # It is used by write_basic_package_version_file() as input file for configure_file()
3
+ # to create a version-file which can be installed along a config.cmake file.
4
+ #
5
+ # The created file sets PACKAGE_VERSION_EXACT if the current version string and
6
+ # the requested version string are exactly the same and it sets
7
+ # PACKAGE_VERSION_COMPATIBLE if the current version is equal to the requested version.
8
+ # The tweak version component is ignored.
9
+ # The variable CVF_VERSION must be set before calling configure_file().
10
+
11
+
12
+ if (PACKAGE_FIND_VERSION_RANGE)
13
+ message(AUTHOR_WARNING
14
+ "`find_package()` specify a version range but the version strategy "
15
+ "(ExactVersion) of the module `${PACKAGE_FIND_NAME}` is incompatible "
16
+ "with this request. Only the lower endpoint of the range will be used.")
17
+ endif()
18
+
19
+ set(PACKAGE_VERSION "1.21.2")
20
+
21
+ if("1.21.2" MATCHES "^([0-9]+)\\.([0-9]+)\\.([0-9]+)") # strip the tweak version
22
+ set(CVF_VERSION_MAJOR "${CMAKE_MATCH_1}")
23
+ set(CVF_VERSION_MINOR "${CMAKE_MATCH_2}")
24
+ set(CVF_VERSION_PATCH "${CMAKE_MATCH_3}")
25
+
26
+ if(NOT CVF_VERSION_MAJOR VERSION_EQUAL 0)
27
+ string(REGEX REPLACE "^0+" "" CVF_VERSION_MAJOR "${CVF_VERSION_MAJOR}")
28
+ endif()
29
+ if(NOT CVF_VERSION_MINOR VERSION_EQUAL 0)
30
+ string(REGEX REPLACE "^0+" "" CVF_VERSION_MINOR "${CVF_VERSION_MINOR}")
31
+ endif()
32
+ if(NOT CVF_VERSION_PATCH VERSION_EQUAL 0)
33
+ string(REGEX REPLACE "^0+" "" CVF_VERSION_PATCH "${CVF_VERSION_PATCH}")
34
+ endif()
35
+
36
+ set(CVF_VERSION_NO_TWEAK "${CVF_VERSION_MAJOR}.${CVF_VERSION_MINOR}.${CVF_VERSION_PATCH}")
37
+ else()
38
+ set(CVF_VERSION_NO_TWEAK "1.21.2")
39
+ endif()
40
+
41
+ if(PACKAGE_FIND_VERSION MATCHES "^([0-9]+)\\.([0-9]+)\\.([0-9]+)") # strip the tweak version
42
+ set(REQUESTED_VERSION_MAJOR "${CMAKE_MATCH_1}")
43
+ set(REQUESTED_VERSION_MINOR "${CMAKE_MATCH_2}")
44
+ set(REQUESTED_VERSION_PATCH "${CMAKE_MATCH_3}")
45
+
46
+ if(NOT REQUESTED_VERSION_MAJOR VERSION_EQUAL 0)
47
+ string(REGEX REPLACE "^0+" "" REQUESTED_VERSION_MAJOR "${REQUESTED_VERSION_MAJOR}")
48
+ endif()
49
+ if(NOT REQUESTED_VERSION_MINOR VERSION_EQUAL 0)
50
+ string(REGEX REPLACE "^0+" "" REQUESTED_VERSION_MINOR "${REQUESTED_VERSION_MINOR}")
51
+ endif()
52
+ if(NOT REQUESTED_VERSION_PATCH VERSION_EQUAL 0)
53
+ string(REGEX REPLACE "^0+" "" REQUESTED_VERSION_PATCH "${REQUESTED_VERSION_PATCH}")
54
+ endif()
55
+
56
+ set(REQUESTED_VERSION_NO_TWEAK
57
+ "${REQUESTED_VERSION_MAJOR}.${REQUESTED_VERSION_MINOR}.${REQUESTED_VERSION_PATCH}")
58
+ else()
59
+ set(REQUESTED_VERSION_NO_TWEAK "${PACKAGE_FIND_VERSION}")
60
+ endif()
61
+
62
+ if(REQUESTED_VERSION_NO_TWEAK STREQUAL CVF_VERSION_NO_TWEAK)
63
+ set(PACKAGE_VERSION_COMPATIBLE TRUE)
64
+ else()
65
+ set(PACKAGE_VERSION_COMPATIBLE FALSE)
66
+ endif()
67
+
68
+ if(PACKAGE_FIND_VERSION STREQUAL PACKAGE_VERSION)
69
+ set(PACKAGE_VERSION_EXACT TRUE)
70
+ endif()
71
+
72
+
73
+ # if the installed or the using project don't have CMAKE_SIZEOF_VOID_P set, ignore it:
74
+ if("${CMAKE_SIZEOF_VOID_P}" STREQUAL "" OR "8" STREQUAL "")
75
+ return()
76
+ endif()
77
+
78
+ # check that the installed version has the same 32/64bit-ness as the one which is currently searching:
79
+ if(NOT CMAKE_SIZEOF_VOID_P STREQUAL "8")
80
+ math(EXPR installedBits "8 * 8")
81
+ set(PACKAGE_VERSION "${PACKAGE_VERSION} (${installedBits}bit)")
82
+ set(PACKAGE_VERSION_UNSUITABLE TRUE)
83
+ endif()
@@ -0,0 +1,108 @@
1
+ # Generated by CMake
2
+
3
+ if("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}" LESS 2.8)
4
+ message(FATAL_ERROR "CMake >= 2.8.12 required")
5
+ endif()
6
+ if(CMAKE_VERSION VERSION_LESS "2.8.12")
7
+ message(FATAL_ERROR "CMake >= 2.8.12 required")
8
+ endif()
9
+ cmake_policy(PUSH)
10
+ cmake_policy(VERSION 2.8.12...4.0)
11
+ #----------------------------------------------------------------
12
+ # Generated CMake target import file.
13
+ #----------------------------------------------------------------
14
+
15
+ # Commands may need to know the format version.
16
+ set(CMAKE_IMPORT_FILE_VERSION 1)
17
+
18
+ # Protect against multiple inclusion, which would fail when already imported targets are added once more.
19
+ set(_cmake_targets_defined "")
20
+ set(_cmake_targets_not_defined "")
21
+ set(_cmake_expected_targets "")
22
+ foreach(_cmake_expected_target IN ITEMS heif)
23
+ list(APPEND _cmake_expected_targets "${_cmake_expected_target}")
24
+ if(TARGET "${_cmake_expected_target}")
25
+ list(APPEND _cmake_targets_defined "${_cmake_expected_target}")
26
+ else()
27
+ list(APPEND _cmake_targets_not_defined "${_cmake_expected_target}")
28
+ endif()
29
+ endforeach()
30
+ unset(_cmake_expected_target)
31
+ if(_cmake_targets_defined STREQUAL _cmake_expected_targets)
32
+ unset(_cmake_targets_defined)
33
+ unset(_cmake_targets_not_defined)
34
+ unset(_cmake_expected_targets)
35
+ unset(CMAKE_IMPORT_FILE_VERSION)
36
+ cmake_policy(POP)
37
+ return()
38
+ endif()
39
+ if(NOT _cmake_targets_defined STREQUAL "")
40
+ string(REPLACE ";" ", " _cmake_targets_defined_text "${_cmake_targets_defined}")
41
+ string(REPLACE ";" ", " _cmake_targets_not_defined_text "${_cmake_targets_not_defined}")
42
+ message(FATAL_ERROR "Some (but not all) targets in this export set were already defined.\nTargets Defined: ${_cmake_targets_defined_text}\nTargets not yet defined: ${_cmake_targets_not_defined_text}\n")
43
+ endif()
44
+ unset(_cmake_targets_defined)
45
+ unset(_cmake_targets_not_defined)
46
+ unset(_cmake_expected_targets)
47
+
48
+
49
+ # Compute the installation prefix relative to this file.
50
+ get_filename_component(_IMPORT_PREFIX "${CMAKE_CURRENT_LIST_FILE}" PATH)
51
+ get_filename_component(_IMPORT_PREFIX "${_IMPORT_PREFIX}" PATH)
52
+ get_filename_component(_IMPORT_PREFIX "${_IMPORT_PREFIX}" PATH)
53
+ get_filename_component(_IMPORT_PREFIX "${_IMPORT_PREFIX}" PATH)
54
+ if(_IMPORT_PREFIX STREQUAL "/")
55
+ set(_IMPORT_PREFIX "")
56
+ endif()
57
+
58
+ # Create imported target heif
59
+ add_library(heif STATIC IMPORTED)
60
+
61
+ set_target_properties(heif PROPERTIES
62
+ INTERFACE_COMPILE_DEFINITIONS "LIBHEIF_EXPORTS;HAVE_VISIBILITY"
63
+ INTERFACE_INCLUDE_DIRECTORIES "${_IMPORT_PREFIX}/include"
64
+ INTERFACE_LINK_LIBRARIES "/opt/homebrew/Cellar/x265/4.1/lib/libx265.dylib;/opt/homebrew/Cellar/libde265/1.0.16/lib/libde265.dylib;/opt/homebrew/Cellar/dav1d/1.5.3/lib/libdav1d.dylib;\$<LINK_ONLY:AOM::aom>;\$<LINK_ONLY:AOM::aom>;/opt/homebrew/lib/libjpeg.dylib;/opt/homebrew/lib/libjpeg.dylib;\$<LINK_ONLY:openjp2>;\$<LINK_ONLY:openjp2>;/opt/homebrew/Cellar/x264/r3222/lib/libx264.dylib;/opt/homebrew/Cellar/openh264/2.6.0/lib/libopenh264.dylib"
65
+ )
66
+
67
+ # Load information for each installed configuration.
68
+ file(GLOB _cmake_config_files "${CMAKE_CURRENT_LIST_DIR}/libheif-config-*.cmake")
69
+ foreach(_cmake_config_file IN LISTS _cmake_config_files)
70
+ include("${_cmake_config_file}")
71
+ endforeach()
72
+ unset(_cmake_config_file)
73
+ unset(_cmake_config_files)
74
+
75
+ # Cleanup temporary variables.
76
+ set(_IMPORT_PREFIX)
77
+
78
+ # Loop over all imported files and verify that they actually exist
79
+ foreach(_cmake_target IN LISTS _cmake_import_check_targets)
80
+ if(CMAKE_VERSION VERSION_LESS "3.28"
81
+ OR NOT DEFINED _cmake_import_check_xcframework_for_${_cmake_target}
82
+ OR NOT IS_DIRECTORY "${_cmake_import_check_xcframework_for_${_cmake_target}}")
83
+ foreach(_cmake_file IN LISTS "_cmake_import_check_files_for_${_cmake_target}")
84
+ if(NOT EXISTS "${_cmake_file}")
85
+ message(FATAL_ERROR "The imported target \"${_cmake_target}\" references the file
86
+ \"${_cmake_file}\"
87
+ but this file does not exist. Possible reasons include:
88
+ * The file was deleted, renamed, or moved to another location.
89
+ * An install or uninstall procedure did not complete successfully.
90
+ * The installation package was faulty and contained
91
+ \"${CMAKE_CURRENT_LIST_FILE}\"
92
+ but not all the files it references.
93
+ ")
94
+ endif()
95
+ endforeach()
96
+ endif()
97
+ unset(_cmake_file)
98
+ unset("_cmake_import_check_files_for_${_cmake_target}")
99
+ endforeach()
100
+ unset(_cmake_target)
101
+ unset(_cmake_import_check_targets)
102
+
103
+ # This file does not depend on other imported targets which have
104
+ # been exported from the same project but in a separate export set.
105
+
106
+ # Commands beyond this point should not need to know the version.
107
+ set(CMAKE_IMPORT_FILE_VERSION)
108
+ cmake_policy(POP)
lib/libheif.a ADDED
Binary file
@@ -0,0 +1,15 @@
1
+ prefix=/var/folders/xx/pgt1mtfn3xx3hdys7czt35bh0000gn/T/tmpljmyse36/wheel/platlib
2
+ exec_prefix=${prefix}
3
+ libdir=${exec_prefix}/lib
4
+ includedir=${prefix}/include
5
+
6
+ Name: libheif
7
+ Description: HEIF image codec.
8
+ URL: https://github.com/strukturag/libheif
9
+ Version: 1.21.2
10
+ Requires:
11
+ Requires.private: libde265 x265 openh264 x264 aom dav1d libjpeg libopenjp2
12
+ Libs: -L${libdir} -lheif
13
+ Libs.private: -lc++
14
+ Cflags: -I${includedir}
15
+ Cflags.private: -DLIBHEIF_STATIC_BUILD
@@ -0,0 +1,405 @@
1
+ Metadata-Version: 2.2
2
+ Name: pylibheif
3
+ Version: 1.21.2.post2
4
+ Summary: Python bindings for libheif - HEIC/AVIF/JPEG2000 image codec
5
+ Keywords: heif,heic,avif,jpeg2000,image,codec,libheif
6
+ Author-Email: Curry Tang <twn39@163.com>
7
+ License: LGPL-3.0-or-later
8
+ Classifier: Development Status :: 4 - Beta
9
+ Classifier: Intended Audience :: Developers
10
+ Classifier: License :: OSI Approved :: GNU Lesser General Public License v3 or later (LGPLv3+)
11
+ Classifier: Operating System :: OS Independent
12
+ Classifier: Programming Language :: Python :: 3
13
+ Classifier: Programming Language :: Python :: 3.11
14
+ Classifier: Programming Language :: Python :: 3.12
15
+ Classifier: Programming Language :: Python :: 3.13
16
+ Classifier: Programming Language :: Python :: 3.14
17
+ Classifier: Programming Language :: C++
18
+ Classifier: Topic :: Multimedia :: Graphics
19
+ Classifier: Topic :: Multimedia :: Graphics :: Graphics Conversion
20
+ Project-URL: Homepage, https://github.com/twn39/pylibheif
21
+ Project-URL: Repository, https://github.com/twn39/pylibheif
22
+ Project-URL: Documentation, https://github.com/twn39/pylibheif#readme
23
+ Project-URL: Issues, https://github.com/twn39/pylibheif/issues
24
+ Requires-Python: >=3.11
25
+ Requires-Dist: numpy>=1.26.0
26
+ Description-Content-Type: text/markdown
27
+
28
+ # pylibheif
29
+
30
+ Python bindings for [libheif](https://github.com/strukturag/libheif) using pybind11.
31
+
32
+ ## Features
33
+
34
+ - **HEIC/HEIF Support**: Read and write HEIC images (HEVC/H.265 encoded)
35
+ - **AVIF Support**: Read and write AVIF images (AV1 encoded)
36
+ - **JPEG2000 Support**: Read and write JPEG2000 images in HEIF container
37
+ - **NumPy Integration**: Zero-copy access to image data via Python Buffer Protocol
38
+ - **Metadata Support**: Read EXIF and XMP metadata from images
39
+ - **RAII Resource Management**: Automatic resource cleanup with context managers
40
+
41
+ ## Supported Formats
42
+
43
+ | Format | Decoding | Encoding | Codec |
44
+ |--------|----------|----------|-------|
45
+ | HEIC (HEVC/H.265) | ✅ | ✅ | libde265 / x265 |
46
+ | AVIF (AV1) | ✅ | ✅ | DAV1D + AOM |
47
+ | JPEG2000 | ✅ | ✅ | OpenJPEG |
48
+
49
+ ## Requirements
50
+
51
+ - Python >= 3.12
52
+ - NumPy >= 1.26.0
53
+ - CMake >= 3.15
54
+ - C++17 compatible compiler
55
+
56
+ ### System Dependencies
57
+
58
+ ```bash
59
+ # macOS
60
+ brew install openjpeg
61
+
62
+ # Ubuntu/Debian
63
+ sudo apt install libopenjp2-7-dev
64
+ ```
65
+
66
+ ## Installation
67
+
68
+ ```bash
69
+ pip install pylibheif
70
+ ```
71
+
72
+ Or with uv:
73
+ ```bash
74
+ uv pip install pylibheif
75
+ ```
76
+
77
+ ### Building from Source
78
+
79
+ ```bash
80
+ # Clone with submodules
81
+ git clone --recursive https://github.com/twn39/pylibheif.git
82
+ cd pylibheif
83
+
84
+ # Install
85
+ uv pip install -e .
86
+ ```
87
+
88
+ ## Usage
89
+
90
+ ### Reading HEIC/AVIF Images
91
+
92
+ **Using context manager (recommended):**
93
+
94
+ ```python
95
+ import pylibheif
96
+ import numpy as np
97
+
98
+ # Open HEIC file with context manager
99
+ with pylibheif.HeifContext() as ctx:
100
+ ctx.read_from_file('image.heic')
101
+
102
+ # Get primary image handle
103
+ handle = ctx.get_primary_image_handle()
104
+ print(f'Image size: {handle.width}x{handle.height}')
105
+ print(f'Has alpha: {handle.has_alpha}')
106
+
107
+ # Decode to RGB
108
+ img = handle.decode(pylibheif.HeifColorspace.RGB,
109
+ pylibheif.HeifChroma.InterleavedRGB)
110
+
111
+ # Get as NumPy array (zero-copy)
112
+ plane = img.get_plane(pylibheif.HeifChannel.Interleaved, False)
113
+ arr = np.asarray(plane) # shape: (height, width, 3)
114
+ ```
115
+
116
+ **Explicit creation (for more control):**
117
+
118
+ ```python
119
+ import pylibheif
120
+ import numpy as np
121
+
122
+ # Create context explicitly
123
+ ctx = pylibheif.HeifContext()
124
+ ctx.read_from_file('image.heic')
125
+
126
+ handle = ctx.get_primary_image_handle()
127
+ img = handle.decode(pylibheif.HeifColorspace.RGB,
128
+ pylibheif.HeifChroma.InterleavedRGB)
129
+ plane = img.get_plane(pylibheif.HeifChannel.Interleaved, False)
130
+ arr = np.asarray(plane)
131
+
132
+ # Resources are automatically freed when objects go out of scope
133
+ ```
134
+
135
+ ### Writing HEIC/AVIF Images
136
+
137
+ ```python
138
+ import pylibheif
139
+ import numpy as np
140
+
141
+ # Create image from NumPy array
142
+ width, height = 1920, 1080
143
+ img = pylibheif.HeifImage(width, height,
144
+ pylibheif.HeifColorspace.RGB,
145
+ pylibheif.HeifChroma.InterleavedRGB)
146
+ img.add_plane(pylibheif.HeifChannel.Interleaved, width, height, 8)
147
+
148
+ # Fill with data
149
+ plane = img.get_plane(pylibheif.HeifChannel.Interleaved, True)
150
+ arr = np.asarray(plane)
151
+ arr[:] = your_image_data # your RGB data
152
+
153
+ # Encode and save
154
+ ctx = pylibheif.HeifContext()
155
+
156
+ # For HEIC (HEVC)
157
+ encoder = pylibheif.HeifEncoder(pylibheif.HeifCompressionFormat.HEVC)
158
+ # For AVIF (AV1)
159
+ # encoder = pylibheif.HeifEncoder(pylibheif.HeifCompressionFormat.AV1)
160
+ # For JPEG2000
161
+ # encoder = pylibheif.HeifEncoder(pylibheif.HeifCompressionFormat.JPEG2000)
162
+
163
+ encoder.set_lossy_quality(85)
164
+ encoder.encode_image(ctx, img)
165
+ ctx.write_to_file('output.heic')
166
+ ```
167
+
168
+ ### Converting HEIC to JPEG
169
+
170
+ ```python
171
+ import pylibheif
172
+ import numpy as np
173
+ from PIL import Image
174
+
175
+ # Decode HEIC
176
+ ctx = pylibheif.HeifContext()
177
+ ctx.read_from_file('input.heic')
178
+ handle = ctx.get_primary_image_handle()
179
+ img = handle.decode(pylibheif.HeifColorspace.RGB,
180
+ pylibheif.HeifChroma.InterleavedRGB)
181
+
182
+ # Get NumPy array
183
+ plane = img.get_plane(pylibheif.HeifChannel.Interleaved, False)
184
+ arr = np.asarray(plane)
185
+
186
+ # Save as JPEG using PIL
187
+ pil_img = Image.fromarray(arr)
188
+ pil_img.save('output.jpg', 'JPEG', quality=85)
189
+ ```
190
+
191
+ ### Reading Metadata
192
+
193
+ ```python
194
+ import pylibheif
195
+
196
+ ctx = pylibheif.HeifContext()
197
+ ctx.read_from_file('image.heic')
198
+ handle = ctx.get_primary_image_handle()
199
+
200
+ # Get metadata block IDs
201
+ exif_ids = handle.get_metadata_block_ids('Exif')
202
+ for id in exif_ids:
203
+ metadata_type = handle.get_metadata_block_type(id)
204
+ metadata_bytes = handle.get_metadata_block(id)
205
+ print(f'Metadata type: {metadata_type}, size: {len(metadata_bytes)}')
206
+ ```
207
+
208
+ ## API Reference
209
+
210
+ ### class `pylibheif.HeifContext`
211
+
212
+ Manages the valid lifetime of libheif context. It is the main entry point (root object) for high-level API.
213
+
214
+ #### Methods
215
+
216
+ **`__init__()`**
217
+ Creates a new empty context.
218
+
219
+ **`read_from_file(filename: str) -> None`**
220
+ Reads a HEIF file from the given filename.
221
+ - `filename`: Path to the HEIF file.
222
+
223
+ **`read_from_memory(data: bytes) -> None`**
224
+ Reads a HEIF file from a bytes object.
225
+ - `data`: Bytes containing the file content.
226
+
227
+ **`write_to_file(filename: str) -> None`**
228
+ Writes the current context to a file.
229
+ - `filename`: Destination path.
230
+
231
+ **`write_to_bytes() -> bytes`**
232
+ Writes the current context to a bytes object.
233
+ - Returns: `bytes` object containing the encoded file data.
234
+
235
+ **`get_primary_image_handle() -> HeifImageHandle`**
236
+ Gets the handle for the primary image in the file.
237
+ - Returns: `HeifImageHandle` for the primary image.
238
+
239
+ **`get_image_handle(id: int) -> HeifImageHandle`**
240
+ Gets the handle for a specific image ID.
241
+ - `id`: The ID of the image (see `get_list_of_top_level_image_IDs`).
242
+ - Returns: `HeifImageHandle`.
243
+
244
+ **`get_list_of_top_level_image_IDs() -> List[int]`**
245
+ Gets a list of IDs of all top-level images in the file.
246
+ - Returns: List of integer IDs.
247
+
248
+ ---
249
+
250
+ ### class `pylibheif.HeifImageHandle`
251
+
252
+ Represents a compressed image within the HEIF file.
253
+
254
+ #### Properties
255
+
256
+ - **`width`** *(int)*: The width of the image.
257
+ - **`height`** *(int)*: The height of the image.
258
+ - **`has_alpha`** *(bool)*: True if the image has an alpha channel.
259
+
260
+ #### Methods
261
+
262
+ **`decode(colorspace: HeifColorspace = HeifColorspace.RGB, chroma: HeifChroma = HeifChroma.InterleavedRGB) -> HeifImage`**
263
+ Decodes the image handle into an uncompressed `HeifImage`.
264
+ - `colorspace`: Target colorspace (default: RGB).
265
+ - `chroma`: Target chroma format (default: InterleavedRGB).
266
+ - Returns: Decoded `HeifImage`.
267
+
268
+ **`get_metadata_block_ids(type_filter: str = "") -> List[str]`**
269
+ Gets a list of metadata block IDs attached to this image.
270
+ - `type_filter`: Optional filter string (e.g. "Exif", "XMP").
271
+ - Returns: List of metadata ID strings.
272
+
273
+ **`get_metadata_block_type(id: str) -> str`**
274
+ Gets the type string of a specific metadata block.
275
+ - `id`: Metadata ID.
276
+ - Returns: Type string (e.g. "Exif").
277
+
278
+ **`get_metadata_block(id: str) -> bytes`**
279
+ Gets the raw data of a metadata block.
280
+ - `id`: Metadata ID.
281
+ - Returns: `bytes` object containing the metadata.
282
+
283
+ ---
284
+
285
+ ### class `pylibheif.HeifImage`
286
+
287
+ Represents an uncompressed image containing pixel data. Supports the Python Buffer Protocol for zero-copy access with NumPy.
288
+
289
+ #### Properties
290
+
291
+ - **`width`** *(int)*: The width of the image.
292
+ - **`height`** *(int)*: The height of the image.
293
+
294
+ #### Methods
295
+
296
+ **`__init__(width: int, height: int, colorspace: HeifColorspace, chroma: HeifChroma)`**
297
+ Creates a new empty image.
298
+ - `width`: Image width.
299
+ - `height`: Image height.
300
+ - `colorspace`: Image colorspace.
301
+ - `chroma`: Image chroma format.
302
+
303
+ **`add_plane(channel: HeifChannel, width: int, height: int, bit_depth: int) -> None`**
304
+ Adds a new plane to the image.
305
+ - `channel`: The channel type (e.g. `HeifChannel.Interleaved`).
306
+ - `width`: Width of the plane.
307
+ - `height`: Height of the plane.
308
+ - `bit_depth`: Bit depth (e.g. 8).
309
+
310
+ **`get_plane(channel: HeifChannel, writeable: bool = False) -> HeifPlane`**
311
+ Gets a plane object that supports the buffer protocol.
312
+ - `channel`: The channel to retrieve.
313
+ - `writeable`: Whether the buffer should be writable.
314
+ - Returns: `HeifPlane` object (wrappable with `np.asarray()`).
315
+
316
+ ---
317
+
318
+ ### class `pylibheif.HeifEncoder`
319
+
320
+ Controls the encoding process.
321
+
322
+ #### Methods
323
+
324
+ **`__init__(format: HeifCompressionFormat)`**
325
+ Creates a new encoder for the specified format.
326
+ - `format`: Compression format (e.g. `HeifCompressionFormat.HEVC`).
327
+
328
+ **`set_lossy_quality(quality: int) -> None`**
329
+ Sets the quality for lossy compression.
330
+ - `quality`: Integer between 0 (lowest) and 100 (highest).
331
+
332
+ **`set_parameter(name: str, value: str) -> None`**
333
+ Sets a low-level encoder parameter.
334
+ - `name`: Parameter name (e.g. "speed" for AV1).
335
+ - `value`: Parameter value.
336
+
337
+ **`encode_image(context: HeifContext, image: HeifImage) -> None`**
338
+ Encodes the given image and appends it to the context.
339
+ - `context`: The destination `HeifContext`.
340
+ - `image`: The source `HeifImage` to encode.
341
+
342
+ ---
343
+
344
+ ### Enums
345
+
346
+ #### `pylibheif.HeifColorspace`
347
+ - `RGB`, `YCbCr`, `Monochrome`, `Undefined`
348
+
349
+ #### `pylibheif.HeifChroma`
350
+ - `InterleavedRGB`: Interleaved R, G, B bytes.
351
+ - `InterleavedRGBA`: Interleaved R, G, B, A bytes.
352
+ - `C420`: YUV 4:2:0 planar.
353
+ - `C422`: YUV 4:2:2 planar.
354
+ - `C444`: YUV 4:4:4 planar.
355
+ - `Monochrome`.
356
+
357
+ #### `pylibheif.HeifChannel`
358
+ - `Interleaved`: For interleaved RGB/RGBA.
359
+ - `Y`, `Cb`, `Cr`: For YUV planar.
360
+ - `R`, `G`, `B`: For RGB planar.
361
+ - `Alpha`: For Alpha channel.
362
+
363
+ #### `pylibheif.HeifCompressionFormat`
364
+ - `HEVC`: H.265 (libx265).
365
+ - `AV1`: AV1 (AOM/RAV1E/SVT).
366
+ - `JPEG`: JPEG.
367
+ - `JPEG2000`: JPEG 2000 (OpenJPEG).
368
+
369
+ ## Building from Source
370
+
371
+ ```bash
372
+ # Clone with submodules
373
+ git clone --recursive https://github.com/your-username/pylibheif.git
374
+ cd pylibheif
375
+
376
+ # Build
377
+ uv pip install -e .
378
+ ```
379
+
380
+ ## Performance
381
+
382
+ Benchmarks on 1920x1080 RGB image (Apple Silicon):
383
+
384
+ | Operation | pylibheif | pillow-heif | Note |
385
+ |:---|:---:|:---:|:---|
386
+ | HEVC Decode | 25 ms | 25 ms | ~39 FPS |
387
+ | HEVC Encode | 279 ms | 272 ms | Quality 80 |
388
+ | AV1 Encode | 91 ms | - | Speed 50 |
389
+
390
+ `pylibheif` offers performance comparable to `pillow-heif` (both wrapper libheif), but exposes a lower-level C++ API for fine-grained control.
391
+
392
+ Run benchmarks yourself:
393
+ ```bash
394
+ uv pip install pillow-heif pytest-benchmark
395
+ uv run pytest tests/test_benchmark.py --benchmark-only
396
+ ```
397
+
398
+ ## License
399
+
400
+ This project is licensed under the LGPL-3.0 License - see the [LICENSE](LICENSE) file for details.
401
+
402
+ ## Acknowledgments
403
+
404
+ - [libheif](https://github.com/strukturag/libheif) - HEIF/AVIF codec library
405
+ - [pybind11](https://github.com/pybind/pybind11) - C++/Python bindings
@@ -0,0 +1,44 @@
1
+ pylibheif.cpython-314-darwin.so,sha256=Kw1zQmJFUwX2PGSHrg2eC11_C2Rpoe7MdbJTepGZjmI,1465232
2
+ include/libheif/heif_error.h,sha256=buuv0fMvYb1NU_r7rPeHkcFMYIOzG-DH-7mOQI-xl2M,8765
3
+ include/libheif/heif_plugin.h,sha256=phh6v7n8qs9XpZhR7tx1U1qSD2HkaBD9ZsX2dZ8OluI,13118
4
+ include/libheif/heif.h,sha256=lttx6Y--O6YMPgA442G3CyDbCrjHoQ76rHgJMkCSnDI,1351
5
+ include/libheif/heif_entity_groups.h,sha256=x4U5pwoD1BmdNYRkzqPD5Yr6A-82hgC9o9w2DG-Ie_A,1895
6
+ include/libheif/heif_text.h,sha256=4_gegjTlEhG8YsLuyikP76xhk4VLUKWNn3q4jeKbSyg,5502
7
+ include/libheif/heif_tiling.h,sha256=kLI4NA3u_uFdN_s-GKYS200yu5w7dp45qnl2f1f3jMg,5453
8
+ include/libheif/heif_color.h,sha256=F0kvmt5GOkgJP5iHPeuGJUCCETJtd0O0GS8R-1VZgFQ,14427
9
+ include/libheif/heif_cxx.h,sha256=tdB9fHtbxuVb2KILP2LUJ-w5c013X0kZLVnnVB4IMnE,41357
10
+ include/libheif/heif_metadata.h,sha256=fse7pHVkgYzjBY36cY4P4qtCeWB73Rca-7j87L5xrVo,6225
11
+ include/libheif/heif_version.h,sha256=R_2fiedGQk0x-PNuG1W5hpDrMU2QUxksRcZNbXY6m0Q,1275
12
+ include/libheif/heif_brands.h,sha256=JeOWoR7YAG3akn_NsrDelL4uAMRSHbsaQzaDLHfMHUk,10586
13
+ include/libheif/heif_encoding.h,sha256=Eqz-RkGubU34WBvFA0J5JgbnJ8RhWnBKdgrtywko1Uw,16574
14
+ include/libheif/heif_library.h,sha256=xu0O9sYUz5D70eARJLuJ5wj_PcJFq1-Mpw6AHsvHF6M,7943
15
+ include/libheif/heif_regions.h,sha256=qUiOn9Q8tidWjNFWRQB3j2gVwtz_NMScaKiBiYM8mYQ,38812
16
+ include/libheif/heif_security.h,sha256=BfyBApRa2ly_fNeuTd9B4k9579ZLNigDWH2YXG2_-N4,3316
17
+ include/libheif/heif_tai_timestamps.h,sha256=1FDjZmwkJXMsKYcBKoRcWKuESEWUKaC5UWlKDicWeH0,7798
18
+ include/libheif/heif_items.h,sha256=zDci6_hSvJ0BTPiOEIJ9XGfMq73LgzvvjuGVPbHA8m4,9849
19
+ include/libheif/heif_aux_images.h,sha256=ZWIRPKs07k9-HOaKt6AQYrgAAPNdt-ji-_EHILxasr4,7258
20
+ include/libheif/heif_sequences.h,sha256=_H6zhko2pELq-DfVMO8BVk1VyDNzCBiw0SutYs4RhA4,22789
21
+ include/libheif/heif_decoding.h,sha256=lfIrX1wb-eYkf5zkBB2mWNlhWpPLTrOFL7ieV5zNlZw,6332
22
+ include/libheif/heif_properties.h,sha256=ZFN9A_9Jnq6_fICy7Ew_10oZAAyiOxN38i9yO-6QIyM,10721
23
+ include/libheif/heif_image.h,sha256=X888K_zjlJutbnmNX5lglU-vi8prFgdiKIQPL8QAKQQ,13681
24
+ include/libheif/heif_image_handle.h,sha256=7iFydgGAdY6WzAGECrSXHMpuIhnYvHGzyppgNIF3c-c,5134
25
+ include/libheif/heif_uncompressed.h,sha256=TQKIEDnly7GjolFdoI492vhma28V96Gex5FWsKZ2zGk,3868
26
+ include/libheif/heif_context.h,sha256=FfIGQVcB1-M1e8Bde8FTVQbcM0UxSAO5vYoew0v_3-Y,13014
27
+ pylibheif.dylibs/libvmaf.3.dylib,sha256=lcTjGz9G1hkeuh-Ev0VOEOzXstTUOzjdLjAr9ClgcW0,748064
28
+ pylibheif.dylibs/libdav1d.7.dylib,sha256=tjhJqwA_EqyChtFvKLRuYvdvyVNc2XGaUFPiqUbUJaw,798624
29
+ pylibheif.dylibs/libx264.165.dylib,sha256=7c9nVoZBWDmPYhmbpPRf1rX1X9WsWio5lYK1aNdKf9s,1298192
30
+ pylibheif.dylibs/libopenjp2.2.5.4.dylib,sha256=H5iNXa_UvIHu8ttzJYCEgo3BX6QHoBtK7uAqerKZjhU,325968
31
+ pylibheif.dylibs/libde265.0.dylib,sha256=mw2Bp02q-Rmf0lOr0Gdihj2j-UuWD6ndUhDQRIef9d0,422608
32
+ pylibheif.dylibs/libx265.215.dylib,sha256=0HBo8OEcH0SKUdOpcON3korZdB1ncqiyb6Rkiu1CQBY,4923728
33
+ pylibheif.dylibs/libjpeg.8.3.2.dylib,sha256=RMLYdlLWUEf_YBlB5yY9En2gLESSjcS8KnopOXTLxKk,473200
34
+ pylibheif.dylibs/libaom.3.13.1.dylib,sha256=-slvol0iSmqGkxMbc0-sca04zA6UlGjhHkHY9N6_Z0Y,3924256
35
+ pylibheif.dylibs/libopenh264.2.6.0.dylib,sha256=sJHxJ7Vvwa7KrRUGlnxLZg0OsiwZEIf7X8cmZysvZ1o,964688
36
+ lib/libheif.a,sha256=POnFyN4K3eKQdvQ4367RwrSfoVIh_eW_KvyjjpBzBJY,3818520
37
+ lib/pkgconfig/libheif.pc,sha256=2RIo4ggnnFYo5wbwb_PV98D13zP_FUXqd5yCj6-mTrE,457
38
+ lib/cmake/libheif/libheif-config.cmake,sha256=oGWkMDTOt-ctBuVjnkx5esCLHVd38tBC3GyFngQ4Ex4,4593
39
+ lib/cmake/libheif/libheif-config-release.cmake,sha256=NmefsNyqv-yyAObfvRLShZEKExbE98P2Cd28eroyejw,789
40
+ lib/cmake/libheif/libheif-config-version.cmake,sha256=r0Rw3uKsVEzNcMMg60edTBAr9df_-NWIXMYIdIy51Og,3252
41
+ pylibheif-1.21.2.post2.dist-info/RECORD,,
42
+ pylibheif-1.21.2.post2.dist-info/WHEEL,sha256=DQQNi05f3Gr0rtExT3J4XDWeFIC7xBSHbQO7D5gfL1U,141
43
+ pylibheif-1.21.2.post2.dist-info/METADATA,sha256=6LMVtZRo2C641xDBIvzDZpXb7wsMVv6B6JQ6dqLLnjI,11503
44
+ pylibheif-1.21.2.post2.dist-info/licenses/LICENSE,sha256=fDdTdPxIYzjisSIHtLHWfwdQjCB1YbnGO14a-rg3M7s,7636
@@ -0,0 +1,6 @@
1
+ Wheel-Version: 1.0
2
+ Generator: scikit-build-core 0.11.6
3
+ Root-Is-Purelib: false
4
+ Tag: cp314-cp314-macosx_14_0_arm64
5
+ Generator: delocate 0.13.0
6
+