Skip to content

Commit 1d05ec5

Browse files
committed
v0.5.0[ci skip]
1 parent 1dd5caf commit 1d05ec5

File tree

3 files changed

+37
-25
lines changed

3 files changed

+37
-25
lines changed

.github/wheels_m1.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
try:
99
print("Installing cibuildwheel...")
1010
args = [executable]
11-
args += "-m pip install cibuildwheel".split()
11+
args += "-m pip install -U cibuildwheel".split()
1212
run(args, check=True)
1313
print("Start building...")
1414
modified_env = dict(environ)

CHANGELOG.md

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

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

5-
## [0.5.0 - 2022-07-23]
5+
## [0.5.0 - 2022-07-21]
66

77
Thumbnails was reworked, if you was not use them before, then this release is fully compatible with `0.4.0` version.
88
It is a final API release, no more further changes to existing API are planned, only bugfixes if any and etc.

README.md

Lines changed: 35 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,14 @@ python3 -m pip install pillow-heif
3636

3737
## Example of use as a Pillow plugin
3838
```python3
39-
from PIL import Image, ImageSequence
39+
from PIL import Image
4040
from pillow_heif import register_heif_opener
4141

4242
register_heif_opener()
4343

44-
image = Image.open("images/input.heic") # do whatever need with a Pillow image
45-
for i, frame in enumerate(ImageSequence.Iterator(image)):
46-
rotated = frame.rotate(13)
47-
rotated.save(f"rotated_frame{i}.heic", quality=90)
44+
im = Image.open("images/input.heic") # do whatever need with a Pillow image
45+
im = im.rotate(13)
46+
im.save(f"rotated_image.heic", quality=90)
4847
```
4948

5049
## 16 bit PNG to 10 bit HEIF using OpenCV
@@ -68,8 +67,8 @@ import cv2
6867
import pillow_heif
6968

7069
heif_file = pillow_heif.open_heif("images/rgb12.heif", convert_hdr_to_8bit=False)
71-
heif_file[0].convert_to("BGRA;16" if heif_file[0].has_alpha else "BGR;16")
72-
np_array = np.asarray(heif_file[0])
70+
heif_file.convert_to("BGRA;16" if heif_file.has_alpha else "BGR;16")
71+
np_array = np.asarray(heif_file)
7372
cv2.imwrite("rgb16.png", np_array)
7473
```
7574

@@ -79,37 +78,50 @@ import pillow_heif
7978

8079
if pillow_heif.is_supported("images/rgb10.heif"):
8180
heif_file = pillow_heif.open_heif("images/rgb10.heif", convert_hdr_to_8bit=False)
82-
print("image mode:", heif_file[0].mode)
83-
print("image data length:", len(heif_file[0].data))
84-
print("image data stride:", heif_file[0].stride)
85-
heif_file[0].convert_to("RGB;16") # convert 10 bit image to RGB 16 bit.
86-
print("image mode:", heif_file[0].mode)
81+
print("image mode:", heif_file.mode)
82+
print("image data length:", len(heif_file.data))
83+
print("image data stride:", heif_file.stride)
84+
heif_file.convert_to("RGB;16") # convert 10 bit image to RGB 16 bit.
85+
print("image mode:", heif_file.mode)
8786
```
8887

8988
## Get decoded image data as a Numpy array
9089
```python3
9190
import numpy as np
9291
import pillow_heif
9392

94-
if pillow_heif.is_supported("images/rgb8_512_512_1_0.heic"):
95-
heif_file = pillow_heif.open_heif("images/rgb8_512_512_1_0.heic")
96-
np_array = np.asarray(heif_file[0])
93+
if pillow_heif.is_supported("input.heic"):
94+
heif_file = pillow_heif.open_heif("input.heic")
95+
np_array = np.asarray(heif_file)
9796
```
9897

99-
## Scaling and adding thumbnails
98+
## Adding & Removing thumbnails
10099
```python3
101100
import pillow_heif
102101

103102
if pillow_heif.is_supported("input.heic"):
104103
heif_file = pillow_heif.open_heif("input.heic")
105-
for img in heif_file: # you still can use it without iteration, like before.
106-
img.scale(1024, 768) # scaling each image in file.
107-
heif_file.add_thumbnails([768, 512, 256]) # add three new thumbnail boxes.
108-
# default quality is probably ~77 in x265, set it a bit lower.
109-
heif_file.save("output.heic", quality=70, save_all=False) # save_all is True by default.
104+
pillow_heif.add_thumbnails(heif_file, [768, 512, 256]) # add three new thumbnail boxes.
105+
heif_file.save("output_with_thumbnails.heic")
106+
heif_file.thumbnails.clear() # clear list with thumbnails.
107+
heif_file.save("output_without_thumbnails.heic")
108+
```
109+
110+
## (Pillow)Adding & Removing thumbnails
111+
```python3
112+
from PIL import Image
113+
import pillow_heif
114+
115+
pillow_heif.register_heif_opener()
116+
117+
im = Image.open("input.heic")
118+
pillow_heif.add_thumbnails(im, [768, 512, 256]) # add three new thumbnail boxes.
119+
im.save("output_with_thumbnails.heic")
120+
im.info["thumbnails"].clear() # clear list with thumbnails.
121+
im.save("output_without_thumbnails.heic")
110122
```
111123

112-
## Using thumbnails when they are present in a file(from version 0.5.0)
124+
## Using thumbnails when they are present in a file
113125
```python3
114126
import pillow_heif
115127

@@ -120,7 +132,7 @@ if pillow_heif.is_supported("input.heic"):
120132
print(img) # This will be a thumbnail or if thumbnail is not avalaible then an original.
121133
```
122134

123-
## (Pillow)Using thumbnails when they are present in a file(from version 0.5.0)
135+
## (Pillow)Using thumbnails when they are present in a file
124136
```python3
125137
from PIL import Image, ImageSequence
126138
import pillow_heif

0 commit comments

Comments
 (0)