pylibheif 1.21.2__cp312-cp312-macosx_26_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.
- include/libheif/heif.h +41 -0
- include/libheif/heif_aux_images.h +182 -0
- include/libheif/heif_brands.h +376 -0
- include/libheif/heif_color.h +363 -0
- include/libheif/heif_context.h +329 -0
- include/libheif/heif_cxx.h +1390 -0
- include/libheif/heif_decoding.h +172 -0
- include/libheif/heif_encoding.h +395 -0
- include/libheif/heif_entity_groups.h +60 -0
- include/libheif/heif_error.h +304 -0
- include/libheif/heif_image.h +355 -0
- include/libheif/heif_image_handle.h +129 -0
- include/libheif/heif_items.h +260 -0
- include/libheif/heif_library.h +219 -0
- include/libheif/heif_metadata.h +136 -0
- include/libheif/heif_plugin.h +378 -0
- include/libheif/heif_properties.h +235 -0
- include/libheif/heif_regions.h +868 -0
- include/libheif/heif_security.h +107 -0
- include/libheif/heif_sequences.h +644 -0
- include/libheif/heif_tai_timestamps.h +202 -0
- include/libheif/heif_text.h +161 -0
- include/libheif/heif_tiling.h +137 -0
- include/libheif/heif_uncompressed.h +109 -0
- include/libheif/heif_version.h +38 -0
- lib/cmake/libheif/libheif-config-release.cmake +19 -0
- lib/cmake/libheif/libheif-config-version.cmake +83 -0
- lib/cmake/libheif/libheif-config.cmake +108 -0
- lib/libheif.a +0 -0
- lib/pkgconfig/libheif.pc +15 -0
- pylibheif-1.21.2.dist-info/METADATA +239 -0
- pylibheif-1.21.2.dist-info/RECORD +34 -0
- pylibheif-1.21.2.dist-info/WHEEL +5 -0
- pylibheif.cpython-312-darwin.so +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;HAVE_LIBSHARPYUV=1"
|
|
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>;\$<LINK_ONLY:openjp2>;\$<LINK_ONLY:openjp2>;/opt/homebrew/Cellar/x264/r3222/lib/libx264.dylib;/opt/homebrew/opt/webp/lib/libsharpyuv.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
|
lib/pkgconfig/libheif.pc
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
prefix=/var/folders/23/2pq3q16d1nn_mvwz51ct825w0000gq/T/tmphrnb0i2t/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 x264 aom dav1d libopenjp2 libsharpyuv
|
|
12
|
+
Libs: -L${libdir} -lheif
|
|
13
|
+
Libs.private: -lc++
|
|
14
|
+
Cflags: -I${includedir}
|
|
15
|
+
Cflags.private: -DLIBHEIF_STATIC_BUILD
|
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
Metadata-Version: 2.2
|
|
2
|
+
Name: pylibheif
|
|
3
|
+
Version: 1.21.2
|
|
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
|
+
# Clone with submodules
|
|
70
|
+
git clone --recursive https://github.com/your-username/pylibheif.git
|
|
71
|
+
cd pylibheif
|
|
72
|
+
|
|
73
|
+
# Install with uv (recommended)
|
|
74
|
+
uv pip install -e .
|
|
75
|
+
|
|
76
|
+
# Or with pip
|
|
77
|
+
pip install -e .
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
## Usage
|
|
81
|
+
|
|
82
|
+
### Reading HEIC/AVIF Images
|
|
83
|
+
|
|
84
|
+
**Using context manager (recommended):**
|
|
85
|
+
|
|
86
|
+
```python
|
|
87
|
+
import pylibheif
|
|
88
|
+
import numpy as np
|
|
89
|
+
|
|
90
|
+
# Open HEIC file with context manager
|
|
91
|
+
with pylibheif.HeifContext() as ctx:
|
|
92
|
+
ctx.read_from_file('image.heic')
|
|
93
|
+
|
|
94
|
+
# Get primary image handle
|
|
95
|
+
handle = ctx.get_primary_image_handle()
|
|
96
|
+
print(f'Image size: {handle.width}x{handle.height}')
|
|
97
|
+
print(f'Has alpha: {handle.has_alpha}')
|
|
98
|
+
|
|
99
|
+
# Decode to RGB
|
|
100
|
+
img = handle.decode(pylibheif.HeifColorspace.RGB,
|
|
101
|
+
pylibheif.HeifChroma.InterleavedRGB)
|
|
102
|
+
|
|
103
|
+
# Get as NumPy array (zero-copy)
|
|
104
|
+
plane = img.get_plane(pylibheif.HeifChannel.Interleaved, False)
|
|
105
|
+
arr = np.asarray(plane) # shape: (height, width, 3)
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
**Explicit creation (for more control):**
|
|
109
|
+
|
|
110
|
+
```python
|
|
111
|
+
import pylibheif
|
|
112
|
+
import numpy as np
|
|
113
|
+
|
|
114
|
+
# Create context explicitly
|
|
115
|
+
ctx = pylibheif.HeifContext()
|
|
116
|
+
ctx.read_from_file('image.heic')
|
|
117
|
+
|
|
118
|
+
handle = ctx.get_primary_image_handle()
|
|
119
|
+
img = handle.decode(pylibheif.HeifColorspace.RGB,
|
|
120
|
+
pylibheif.HeifChroma.InterleavedRGB)
|
|
121
|
+
plane = img.get_plane(pylibheif.HeifChannel.Interleaved, False)
|
|
122
|
+
arr = np.asarray(plane)
|
|
123
|
+
|
|
124
|
+
# Resources are automatically freed when objects go out of scope
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
### Writing HEIC/AVIF Images
|
|
128
|
+
|
|
129
|
+
```python
|
|
130
|
+
import pylibheif
|
|
131
|
+
import numpy as np
|
|
132
|
+
|
|
133
|
+
# Create image from NumPy array
|
|
134
|
+
width, height = 1920, 1080
|
|
135
|
+
img = pylibheif.HeifImage(width, height,
|
|
136
|
+
pylibheif.HeifColorspace.RGB,
|
|
137
|
+
pylibheif.HeifChroma.InterleavedRGB)
|
|
138
|
+
img.add_plane(pylibheif.HeifChannel.Interleaved, width, height, 8)
|
|
139
|
+
|
|
140
|
+
# Fill with data
|
|
141
|
+
plane = img.get_plane(pylibheif.HeifChannel.Interleaved, True)
|
|
142
|
+
arr = np.asarray(plane)
|
|
143
|
+
arr[:] = your_image_data # your RGB data
|
|
144
|
+
|
|
145
|
+
# Encode and save
|
|
146
|
+
ctx = pylibheif.HeifContext()
|
|
147
|
+
|
|
148
|
+
# For HEIC (HEVC)
|
|
149
|
+
encoder = pylibheif.HeifEncoder(pylibheif.HeifCompressionFormat.HEVC)
|
|
150
|
+
# For AVIF (AV1)
|
|
151
|
+
# encoder = pylibheif.HeifEncoder(pylibheif.HeifCompressionFormat.AV1)
|
|
152
|
+
# For JPEG2000
|
|
153
|
+
# encoder = pylibheif.HeifEncoder(pylibheif.HeifCompressionFormat.JPEG2000)
|
|
154
|
+
|
|
155
|
+
encoder.set_lossy_quality(85)
|
|
156
|
+
encoder.encode_image(ctx, img)
|
|
157
|
+
ctx.write_to_file('output.heic')
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
### Converting HEIC to JPEG
|
|
161
|
+
|
|
162
|
+
```python
|
|
163
|
+
import pylibheif
|
|
164
|
+
import numpy as np
|
|
165
|
+
from PIL import Image
|
|
166
|
+
|
|
167
|
+
# Decode HEIC
|
|
168
|
+
ctx = pylibheif.HeifContext()
|
|
169
|
+
ctx.read_from_file('input.heic')
|
|
170
|
+
handle = ctx.get_primary_image_handle()
|
|
171
|
+
img = handle.decode(pylibheif.HeifColorspace.RGB,
|
|
172
|
+
pylibheif.HeifChroma.InterleavedRGB)
|
|
173
|
+
|
|
174
|
+
# Get NumPy array
|
|
175
|
+
plane = img.get_plane(pylibheif.HeifChannel.Interleaved, False)
|
|
176
|
+
arr = np.asarray(plane)
|
|
177
|
+
|
|
178
|
+
# Save as JPEG using PIL
|
|
179
|
+
pil_img = Image.fromarray(arr)
|
|
180
|
+
pil_img.save('output.jpg', 'JPEG', quality=85)
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
### Reading Metadata
|
|
184
|
+
|
|
185
|
+
```python
|
|
186
|
+
import pylibheif
|
|
187
|
+
|
|
188
|
+
ctx = pylibheif.HeifContext()
|
|
189
|
+
ctx.read_from_file('image.heic')
|
|
190
|
+
handle = ctx.get_primary_image_handle()
|
|
191
|
+
|
|
192
|
+
# Get metadata block IDs
|
|
193
|
+
exif_ids = handle.get_metadata_block_ids('Exif')
|
|
194
|
+
for id in exif_ids:
|
|
195
|
+
metadata_type = handle.get_metadata_block_type(id)
|
|
196
|
+
metadata_bytes = handle.get_metadata_block(id)
|
|
197
|
+
print(f'Metadata type: {metadata_type}, size: {len(metadata_bytes)}')
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
## API Reference
|
|
201
|
+
|
|
202
|
+
### Classes
|
|
203
|
+
|
|
204
|
+
- `HeifContext`: Main context for reading/writing HEIF files
|
|
205
|
+
- `HeifImageHandle`: Handle to a decoded image with metadata
|
|
206
|
+
- `HeifImage`: Raw image data with buffer protocol support
|
|
207
|
+
- `HeifEncoder`: Encoder for creating HEIF files
|
|
208
|
+
- `HeifPlane`: Image plane with NumPy buffer protocol
|
|
209
|
+
|
|
210
|
+
### Enums
|
|
211
|
+
|
|
212
|
+
- `HeifColorspace`: RGB, YCbCr, Monochrome
|
|
213
|
+
- `HeifChroma`: C420, C422, C444, InterleavedRGB, InterleavedRGBA
|
|
214
|
+
- `HeifChannel`: Y, Cb, Cr, R, G, B, Alpha, Interleaved
|
|
215
|
+
- `HeifCompressionFormat`: HEVC, AV1, JPEG, JPEG2000
|
|
216
|
+
|
|
217
|
+
### Exceptions
|
|
218
|
+
|
|
219
|
+
- `HeifError`: Base exception for all libheif errors
|
|
220
|
+
|
|
221
|
+
## Building from Source
|
|
222
|
+
|
|
223
|
+
```bash
|
|
224
|
+
# Clone with submodules
|
|
225
|
+
git clone --recursive https://github.com/your-username/pylibheif.git
|
|
226
|
+
cd pylibheif
|
|
227
|
+
|
|
228
|
+
# Build
|
|
229
|
+
uv pip install -e .
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
## License
|
|
233
|
+
|
|
234
|
+
This project is licensed under the LGPL-3.0 License - see the [LICENSE](LICENSE) file for details.
|
|
235
|
+
|
|
236
|
+
## Acknowledgments
|
|
237
|
+
|
|
238
|
+
- [libheif](https://github.com/strukturag/libheif) - HEIF/AVIF codec library
|
|
239
|
+
- [pybind11](https://github.com/pybind/pybind11) - C++/Python bindings
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
include/libheif/heif.h,sha256=lttx6Y--O6YMPgA442G3CyDbCrjHoQ76rHgJMkCSnDI,1351
|
|
2
|
+
include/libheif/heif_aux_images.h,sha256=ZWIRPKs07k9-HOaKt6AQYrgAAPNdt-ji-_EHILxasr4,7258
|
|
3
|
+
include/libheif/heif_brands.h,sha256=JeOWoR7YAG3akn_NsrDelL4uAMRSHbsaQzaDLHfMHUk,10586
|
|
4
|
+
include/libheif/heif_color.h,sha256=F0kvmt5GOkgJP5iHPeuGJUCCETJtd0O0GS8R-1VZgFQ,14427
|
|
5
|
+
include/libheif/heif_context.h,sha256=FfIGQVcB1-M1e8Bde8FTVQbcM0UxSAO5vYoew0v_3-Y,13014
|
|
6
|
+
include/libheif/heif_cxx.h,sha256=tdB9fHtbxuVb2KILP2LUJ-w5c013X0kZLVnnVB4IMnE,41357
|
|
7
|
+
include/libheif/heif_decoding.h,sha256=lfIrX1wb-eYkf5zkBB2mWNlhWpPLTrOFL7ieV5zNlZw,6332
|
|
8
|
+
include/libheif/heif_encoding.h,sha256=Eqz-RkGubU34WBvFA0J5JgbnJ8RhWnBKdgrtywko1Uw,16574
|
|
9
|
+
include/libheif/heif_entity_groups.h,sha256=x4U5pwoD1BmdNYRkzqPD5Yr6A-82hgC9o9w2DG-Ie_A,1895
|
|
10
|
+
include/libheif/heif_error.h,sha256=buuv0fMvYb1NU_r7rPeHkcFMYIOzG-DH-7mOQI-xl2M,8765
|
|
11
|
+
include/libheif/heif_image.h,sha256=X888K_zjlJutbnmNX5lglU-vi8prFgdiKIQPL8QAKQQ,13681
|
|
12
|
+
include/libheif/heif_image_handle.h,sha256=7iFydgGAdY6WzAGECrSXHMpuIhnYvHGzyppgNIF3c-c,5134
|
|
13
|
+
include/libheif/heif_items.h,sha256=zDci6_hSvJ0BTPiOEIJ9XGfMq73LgzvvjuGVPbHA8m4,9849
|
|
14
|
+
include/libheif/heif_library.h,sha256=xu0O9sYUz5D70eARJLuJ5wj_PcJFq1-Mpw6AHsvHF6M,7943
|
|
15
|
+
include/libheif/heif_metadata.h,sha256=fse7pHVkgYzjBY36cY4P4qtCeWB73Rca-7j87L5xrVo,6225
|
|
16
|
+
include/libheif/heif_plugin.h,sha256=phh6v7n8qs9XpZhR7tx1U1qSD2HkaBD9ZsX2dZ8OluI,13118
|
|
17
|
+
include/libheif/heif_properties.h,sha256=ZFN9A_9Jnq6_fICy7Ew_10oZAAyiOxN38i9yO-6QIyM,10721
|
|
18
|
+
include/libheif/heif_regions.h,sha256=qUiOn9Q8tidWjNFWRQB3j2gVwtz_NMScaKiBiYM8mYQ,38812
|
|
19
|
+
include/libheif/heif_security.h,sha256=BfyBApRa2ly_fNeuTd9B4k9579ZLNigDWH2YXG2_-N4,3316
|
|
20
|
+
include/libheif/heif_sequences.h,sha256=_H6zhko2pELq-DfVMO8BVk1VyDNzCBiw0SutYs4RhA4,22789
|
|
21
|
+
include/libheif/heif_tai_timestamps.h,sha256=1FDjZmwkJXMsKYcBKoRcWKuESEWUKaC5UWlKDicWeH0,7798
|
|
22
|
+
include/libheif/heif_text.h,sha256=4_gegjTlEhG8YsLuyikP76xhk4VLUKWNn3q4jeKbSyg,5502
|
|
23
|
+
include/libheif/heif_tiling.h,sha256=kLI4NA3u_uFdN_s-GKYS200yu5w7dp45qnl2f1f3jMg,5453
|
|
24
|
+
include/libheif/heif_uncompressed.h,sha256=TQKIEDnly7GjolFdoI492vhma28V96Gex5FWsKZ2zGk,3868
|
|
25
|
+
include/libheif/heif_version.h,sha256=SWRAzPXZ7d3RDHKjEhtTu41EpmLTfmnDnG1vNpzGmg4,1275
|
|
26
|
+
lib/cmake/libheif/libheif-config-release.cmake,sha256=NmefsNyqv-yyAObfvRLShZEKExbE98P2Cd28eroyejw,789
|
|
27
|
+
lib/cmake/libheif/libheif-config-version.cmake,sha256=r0Rw3uKsVEzNcMMg60edTBAr9df_-NWIXMYIdIy51Og,3252
|
|
28
|
+
lib/cmake/libheif/libheif-config.cmake,sha256=JANr5p8tUitjiUSXtm9ifh1yZGy_WzAmY89jSMfrKuk,4535
|
|
29
|
+
lib/libheif.a,sha256=cS1ZEcGf43A-SddpwFt7fY1jwOZPf1xyNwAlzZjsgnk,3789944
|
|
30
|
+
lib/pkgconfig/libheif.pc,sha256=nNA5zIgb8VS8x1oVaz2qe2kg_ElX5i6F6dgEtWY7oJw,452
|
|
31
|
+
pylibheif.cpython-312-darwin.so,sha256=7q-UKIHcMRkowZcG2oR4UNfDxygIi49juQBpdCfd0Ok,1329072
|
|
32
|
+
pylibheif-1.21.2.dist-info/METADATA,sha256=N-p7UONvNk7G1gsgmT_JaPoknvSFBvjZxAUzVOnhlwA,6634
|
|
33
|
+
pylibheif-1.21.2.dist-info/WHEEL,sha256=J3lK_y7k0T6eQP7gm0rYedCdlQrQkeps4Wm2ycjs0Tc,114
|
|
34
|
+
pylibheif-1.21.2.dist-info/RECORD,,
|
|
Binary file
|