Skip to content

Commit 5ce3038

Browse files
committed
v0.2.1
1 parent 8ba9e88 commit 5ce3038

23 files changed

+911
-879
lines changed

.github/workflows/build-cache-deps.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ jobs:
3535

3636
- name: manylinux preparations
3737
if: matrix.cibw_buildlinux == 'manylinux'
38-
run: echo INSTALL_OS_PACKAGES="yum update -y && yum install -y $OS_PACKAGES" >> $GITHUB_ENV
38+
run: echo INSTALL_OS_PACKAGES="yum makecache && yum install -y $OS_PACKAGES" >> $GITHUB_ENV
3939
env:
4040
OS_PACKAGES: "git-all"
4141

.github/workflows/test-wheels.yaml

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@ jobs:
3333
]
3434

3535
steps:
36+
- name: Delay, waiting Pypi to update.
37+
if: ${{ github.event_name != 'workflow_dispatch' }}
38+
run: sleep 60
39+
3640
- uses: actions/checkout@v3
3741
- name: Set up QEMU
3842
if: matrix.i['arch'] == 'arm64'
@@ -73,6 +77,11 @@ jobs:
7377
python-version: ["3.7", "3.8", "3.9", "3.10"]
7478

7579
steps:
80+
- name: Delay, waiting Pypi to update.
81+
if: ${{ github.event_name != 'workflow_dispatch' }}
82+
run: Start-Sleep -s 60
83+
shell: powershell
84+
7685
- uses: actions/checkout@v3
7786
- name: Set up Python
7887
uses: actions/setup-python@v3
@@ -85,7 +94,7 @@ jobs:
8594
python3 -m pip install --only-binary=:all: pillow_heif
8695
8796
- name: Test wheel
88-
run: cd .. && python3 -m pytest -s pillow_heif
97+
run: cd .. && python3 -m pytest -rs pillow_heif
8998

9099
macos-wheels:
91100
if: ${{ github.event.workflow_run.conclusion == 'success' || github.event_name == 'workflow_dispatch' }}
@@ -96,6 +105,10 @@ jobs:
96105
python-version: ["pypy-3.7", "pypy-3.8", "3.7", "3.8", "3.9", "3.10"]
97106

98107
steps:
108+
- name: Delay, waiting Pypi to update.
109+
if: ${{ github.event_name != 'workflow_dispatch' }}
110+
run: sleep 60
111+
99112
- uses: actions/checkout@v3
100113
- name: Set up Python
101114
uses: actions/setup-python@v3
@@ -109,7 +122,7 @@ jobs:
109122
python3 -m pip install --only-binary=:all: pillow_heif
110123
111124
- name: Test wheel
112-
run: cd .. && python3 -m pytest -s pillow_heif
125+
run: cd .. && python3 -m pytest -rs pillow_heif
113126

114127
manylinux-wheels:
115128
if: ${{ github.event.workflow_run.conclusion == 'success' || github.event_name == 'workflow_dispatch' }}
@@ -120,6 +133,10 @@ jobs:
120133
python-version: ["pypy-3.7", "pypy-3.8", "3.6", "3.7", "3.8", "3.9", "3.10"]
121134

122135
steps:
136+
- name: Delay, waiting Pypi to update.
137+
if: ${{ github.event_name != 'workflow_dispatch' }}
138+
run: sleep 60
139+
123140
- uses: actions/checkout@v3
124141
- name: Set up Python
125142
uses: actions/setup-python@v3
@@ -133,4 +150,4 @@ jobs:
133150
python3 -m pip install --only-binary=:all: pillow_heif
134151
135152
- name: Test wheel
136-
run: cd .. && python3 -m pytest -s pillow_heif
153+
run: cd .. && python3 -m pytest -rs pillow_heif

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
All notable changes to this project will be documented in this file.
44

5-
## [0.2.1 - 2022-04-18]
5+
## [0.2.1 - 2022-04-17]
66

77
### Added
88

README.md

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,9 @@ if pillow_heif.is_supported('input.heic'):
4646
heif_file = pillow_heif.open_heif('input.heic')
4747
for img in heif_file: # you still can use it without iteration, like before.
4848
img.scale(1024, 768) # `libheif` does not provide much operations, that can be done on image, so just scaling it.
49-
# get save mask and set thumb_box=-1 to ignore all thumbs image have.
50-
save_mask = heif_file.get_img_thumb_mask_for_save(pillow_heif.HeifSaveMask.SAVE_ALL, thumb_box=-1)
51-
heif_file.add_thumbs_to_mask(save_mask, [768, 512, 256]) # add three new thumbnail boxes.
49+
heif_file.add_thumbnails([768, 512, 256]) # add three new thumbnail boxes.
5250
# default quality is probably ~77 in x265, set it a bit lower and specify `save mask`.
53-
heif_file.save('output.heic', quality=70, save_mask=save_mask)
51+
heif_file.save('output.heic', quality=70, save_all=False) #save_all is True by default.
5452
exit(0)
5553
```
5654
### [More examples](https://github.com/bigcat88/pillow_heif/tree/master/examples)
@@ -85,7 +83,6 @@ The returned `HeifImageFile` by `Pillow` function `Image.open` has the following
8583
* `metadata` - is a list of dictionaries with `type` and `data` keys, excluding `exif`. May be empty.
8684
* `icc_profile` - contains data and present only when file has `ICC` color profile(`prof` or `rICC`).
8785
* `nclx_profile` - contains data and present only when file has `NCLX` color profile.
88-
* `img_id` - id of image, needed for encoding operations.
8986

9087
### The HeifFile object
9188
The returned `HeifFile` by function `open_heif` or `from_pillow` has the following properties:

docker/test_wheels.Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@ RUN python3 -m pip install --no-deps --only-binary=:all: pillow_heif
1212

1313
COPY . /pillow_heif
1414

15-
RUN python3 -m pytest -s -v pillow_heif/. && echo "**** Test Done ****" && python3 -m pip show pillow_heif
15+
RUN python3 -m pytest -rs -v pillow_heif/. && echo "**** Test Done ****" && python3 -m pip show pillow_heif

docs/BUILDING.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,24 +26,25 @@ Notes:
2626

2727
1. Building for first time will take a long time, if in your system `cmake` version `>=3.16.1` is not present.
2828
2. Arm7(32 bit):
29-
* On Alpine you need install `aom-dev`.
29+
* On Alpine need install `aom-dev`.
3030
* On Ubuntu(22.04+) you need install `libaom-dev`.
31-
* On Ubuntu less then 22.04 you can compile it from source, but `AV1` codecs will be not avalaible.
31+
* On Ubuntu less 22.04 you can compile it from source, but `AV1` codecs will be not available.
3232
* Encoder will not be available if you did not install `x265`. It is not build from source by default on armv7.
3333

3434
### MacOS
3535
```bash
3636
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
3737
brew install x265 libjpeg libde265 libheif
38-
pip3 install --no-binary pillow_heif
38+
pip3 install --no-binary=:all: pillow_heif
3939
```
4040

4141
### Windows
4242
By default, build script assumes that `vcpkg` builds libs in `C:\vcpkg\installed\x64-windows`.
4343
If not, then set `VCPKG_PREFIX` environment variable to your custom path, e.g. `setx VCPKG_PREFIX "D:\vcpkg\installed\x64-windows"`
4444
```bat
4545
vcpkg install aom libheif --triplet=x64-windows
46-
pip3 install --no-binary pillow_heif
46+
pip3 install --no-binary=:all: pillow_heif
4747
```
48+
After that copy `heif.dll`, `aom.dll`, `libde265.dll` and `libx265.dll` from `vcpkg\installed\x64-windows\bin` to site-packages root.
4849

4950
Note: there is no support for 10/12 bit file formats for encoder now on Windows.

examples/opener_display_images.py

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,8 @@
1717
img = Image.open(image_path)
1818
img.load()
1919
for i, frame in enumerate(ImageSequence.Iterator(img)):
20-
# `img.info["thumbnails"]` can be changed in future versions.
21-
# Probably soon will be introduced a new method instead of `Image.frombytes` for thumbnails.
2220
for thumb in img.info["thumbnails"]:
23-
thumb_img = Image.frombytes(
24-
thumb.mode,
25-
thumb.size,
26-
thumb.data,
27-
"raw",
28-
thumb.mode,
29-
thumb.stride,
30-
)
21+
thumb_img = thumb.to_pillow()
3122
thumb_img.show(title=f"Img={i} Thumbnail={thumb.info['thumb_id']}")
3223
img.show(title=f"Image index={i}")
3324
except Exception as e:

examples/reader_add_thumbnails.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import os
2+
import sys
3+
import traceback
4+
from pathlib import Path
5+
6+
import pillow_heif
7+
8+
if __name__ == "__main__":
9+
os.chdir(os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(__file__))), "tests"))
10+
target_folder = "../converted"
11+
os.makedirs(target_folder, exist_ok=True)
12+
image_path = Path("images/pug_1_0.heic")
13+
try:
14+
heif_image = pillow_heif.open_heif(image_path)
15+
result_path = os.path.join(target_folder, f"{image_path.stem}.heic")
16+
heif_image.add_thumbnails([256, 512])
17+
heif_image.save(result_path, quality=35)
18+
heif_image.close()
19+
except Exception as e:
20+
print(f"{repr(e)} during processing {image_path.as_posix()}", file=sys.stderr)
21+
print(traceback.format_exc())
22+
exit(0)

examples/reader_display_images.py

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
import traceback
44
from pathlib import Path
55

6-
from PIL import Image
7-
86
import pillow_heif
97

108
# This demo displays all thumbnails and all images.
@@ -19,23 +17,9 @@
1917
print(f"number of images in file: {len(heif_image)}")
2018
for image in heif_image:
2119
for thumb in image.thumbnails:
22-
thumbnail_img = Image.frombytes(
23-
thumb.mode,
24-
thumb.size,
25-
thumb.data,
26-
"raw",
27-
thumb.mode,
28-
thumb.stride,
29-
)
20+
thumbnail_img = thumb.to_pillow()
3021
thumbnail_img.show(title=f"Thumbnail {thumb.info['thumb_id']}")
31-
_img = Image.frombytes(
32-
image.mode,
33-
image.size,
34-
image.data,
35-
"raw",
36-
image.mode,
37-
image.stride,
38-
)
22+
_img = image.to_pillow()
3923
_img.show(title=f"Image {image.info['img_id']}")
4024
except Exception as e:
4125
print(f"{repr(e)} during processing {image_path.as_posix()}", file=sys.stderr)

examples/reader_remove_image.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import os
2+
import sys
3+
import traceback
4+
from pathlib import Path
5+
6+
import pillow_heif
7+
8+
if __name__ == "__main__":
9+
os.chdir(os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(__file__))), "tests"))
10+
target_folder = "../converted"
11+
os.makedirs(target_folder, exist_ok=True)
12+
image_path = Path("images/pug_2_0.heic")
13+
try:
14+
heif_image = pillow_heif.open_heif(image_path)
15+
result_path = os.path.join(target_folder, f"{image_path.stem}.heic")
16+
del heif_image[1]
17+
heif_image.save(result_path, quality=35)
18+
heif_image.close()
19+
except Exception as e:
20+
print(f"{repr(e)} during processing {image_path.as_posix()}", file=sys.stderr)
21+
print(traceback.format_exc())
22+
exit(0)

0 commit comments

Comments
 (0)