mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-02-04 21:50:54 +03:00
Improved consistency of example paths
This commit is contained in:
parent
cf6ec5e065
commit
888b2f716e
|
@ -332,7 +332,7 @@ choose to resize relative to a given size.
|
||||||
|
|
||||||
from PIL import Image, ImageOps
|
from PIL import Image, ImageOps
|
||||||
size = (100, 150)
|
size = (100, 150)
|
||||||
with Image.open("Tests/images/hopper.webp") as im:
|
with Image.open("hopper.webp") as im:
|
||||||
ImageOps.contain(im, size).save("imageops_contain.webp")
|
ImageOps.contain(im, size).save("imageops_contain.webp")
|
||||||
ImageOps.cover(im, size).save("imageops_cover.webp")
|
ImageOps.cover(im, size).save("imageops_cover.webp")
|
||||||
ImageOps.fit(im, size).save("imageops_fit.webp")
|
ImageOps.fit(im, size).save("imageops_fit.webp")
|
||||||
|
@ -597,7 +597,7 @@ Drawing PostScript
|
||||||
text_y = page_height - text_height - 50 # Distance from the top of the page
|
text_y = page_height - text_height - 50 # Distance from the top of the page
|
||||||
|
|
||||||
# Load the image
|
# Load the image
|
||||||
image_path = os.path.join("img", "hopper.ppm") # Update this with your image path
|
image_path = "hopper.ppm" # Update this with your image path
|
||||||
with Image.open(image_path) as im:
|
with Image.open(image_path) as im:
|
||||||
# Resize the image if it's too large
|
# Resize the image if it's too large
|
||||||
im.thumbnail((page_width - 100, page_height // 2))
|
im.thumbnail((page_width - 100, page_height // 2))
|
||||||
|
@ -690,7 +690,7 @@ Reading from a tar archive
|
||||||
|
|
||||||
from PIL import Image, TarIO
|
from PIL import Image, TarIO
|
||||||
|
|
||||||
fp = TarIO.TarIO("Tests/images/hopper.tar", "hopper.jpg")
|
fp = TarIO.TarIO("hopper.tar", "hopper.jpg")
|
||||||
im = Image.open(fp)
|
im = Image.open(fp)
|
||||||
|
|
||||||
|
|
||||||
|
@ -705,7 +705,6 @@ in the current directory can be saved as JPEGs at reduced quality.
|
||||||
import glob
|
import glob
|
||||||
from PIL import Image
|
from PIL import Image
|
||||||
|
|
||||||
|
|
||||||
def compress_image(source_path, dest_path):
|
def compress_image(source_path, dest_path):
|
||||||
with Image.open(source_path) as img:
|
with Image.open(source_path) as img:
|
||||||
if img.mode != "RGB":
|
if img.mode != "RGB":
|
||||||
|
|
Loading…
Reference in New Issue
Block a user