@@ -68,15 +68,15 @@ def optimize_png(
6868 Arguments:
6969 reduce_colors: Whether to reduce colors using adaptive color pallette (boolean)
7070 values: True | False
71- max_colors: Maximum number of colors
72- if reduce_colors is True (integer between 1 and 256)
71+ max_colors: Maximum number of colors if reduce_colors is True (integer between
72+ 1 and 256)
7373 values: 35 | 64 | 256 | 128 | XX
7474 fast_mode: Whether to use faster but weaker compression (boolean)
7575 values: True | False
7676 remove_transparency: Whether to remove transparency (boolean)
7777 values: True | False
78- background_color: Background color
79- if remove_transparency is True (tuple containing RGB values)
78+ background_color: Background color if remove_transparency is True (tuple
79+ containing RGB values)
8080 values: (255, 255, 255) | (221, 121, 108) | (XX, YY, ZZ)"""
8181
8282 ensure_matches (src , "PNG" )
@@ -110,13 +110,15 @@ def optimize_jpeg(
110110 ** _ ,
111111) -> pathlib .Path | io .BytesIO :
112112 """method to optimize JPEG files using a pure python external optimizer
113- quality: JPEG quality (integer between 1 and 100)
114- values: 50 | 55 | 35 | 100 | XX
115- keep_exif: Whether to keep EXIF data in JPEG (boolean)
116- values: True | False
117- fast_mode: Use the supplied quality value. If turned off, optimizer will
118- get dynamic quality value to ensure better compression
119- values: True | False"""
113+
114+ Arguments:
115+ quality: JPEG quality (integer between 1 and 100)
116+ values: 50 | 55 | 35 | 100 | XX
117+ keep_exif: Whether to keep EXIF data in JPEG (boolean)
118+ values: True | False
119+ fast_mode: Use the supplied quality value. If turned off, optimizer will
120+ get dynamic quality value to ensure better compression
121+ values: True | False"""
120122
121123 ensure_matches (src , "JPEG" )
122124
@@ -179,14 +181,16 @@ def optimize_webp(
179181 ** _ ,
180182) -> pathlib .Path | io .BytesIO :
181183 """method to optimize WebP using Pillow options
182- lossless: Whether to use lossless compression (boolean)
183- values: True | False
184- quality: WebP quality for lossy, effort put into compression
185- for lossless (integer between 0 to 100)
186- values: 30 | 45 | 100 | XX
187- method: Quality/speed trade-off;
188- higher values give better compression (integer between 1 and 6)
189- values: 1 | 2 | 3 | 4 | 5 | 6
184+
185+ Arguments:
186+ lossless: Whether to use lossless compression (boolean);
187+ values: True | False
188+ quality: WebP quality for lossy, effort put into compression for lossless
189+ (integer between 0 to 100);
190+ values: 30 | 45 | 100 | XX
191+ method: Quality/speed trade-off; higher values give better compression (integer
192+ between 1 and 6);
193+ values: 1 | 2 | 3 | 4 | 5 | 6
190194
191195 refer to the link for more details
192196 https://pillow.readthedocs.io/en/stable/handbook/image-file-formats.html#webp"""
@@ -230,18 +234,21 @@ def optimize_gif(
230234 ** _ ,
231235) -> pathlib .Path :
232236 """method to optimize GIFs using gifsicle >= 1.92
233- optimize_level: Optimization level;
234- higher values give better compression (integer between 1 and 3)
235- values: 1 | 2 | 3
236- lossiness: Level of lossy optimization to use;
237- higher values give better compression (integer)
238- values: 20 | 45 | 80 | XX
239- interlace: Whether to interlace the frames (boolean)
240- values: True | False
241- no_extensions: Whether to remove all extension options from GIF (boolean)
242- values: True | False
243- max_colors: Maximum number of colors in resultant GIF (integer between 2 and 256)
244- values: 2 | 86 | 128 | 256 | XX
237+
238+ Arguments:
239+ optimize_level: Optimization level; higher values give better compression
240+ (integer between 1 and 3);
241+ values: 1 | 2 | 3
242+ lossiness: Level of lossy optimization to use; higher values give better
243+ compression (integer)
244+ values: 20 | 45 | 80 | XX
245+ interlace: Whether to interlace the frames (boolean)
246+ values: True | False
247+ no_extensions: Whether to remove all extension options from GIF (boolean)
248+ values: True | False
249+ max_colors: Maximum number of colors in resultant GIF;
250+ (integer between 2 and 256)
251+ values: 2 | 86 | 128 | 256 | XX
245252
246253 refer to the link for more details - https://www.lcdf.org/gifsicle/man.html"""
247254
@@ -282,12 +289,13 @@ def optimize_image(
282289):
283290 """Optimize image, automatically selecting correct optimizer
284291
285- delete_src: whether to remove src file upon success (boolean)
286- values: True | False
287- convert: whether/how to convert from source before optimizing (str or boolean)
288- values: False: don't convert
289- True: convert to format implied by dst suffix
290- "FMT": convert to format FMT (use Pillow names)"""
292+ Arguments:
293+ delete_src: whether to remove src file upon success (boolean)
294+ values: True | False
295+ convert: whether/how to convert from source before optimizing (str or boolean)
296+ values: False: don't convert
297+ True: convert to format implied by dst suffix
298+ "FMT": convert to format FMT (use Pillow names)"""
291299
292300 src_format , dst_format = format_for (src , from_suffix = False ), format_for (dst )
293301
0 commit comments