fotolab 0.18.4__py2.py3-none-any.whl → 0.20.0__py2.py3-none-any.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.
- fotolab/__init__.py +1 -1
- fotolab/auto.py +1 -0
- fotolab/resize.py +85 -25
- {fotolab-0.18.4.dist-info → fotolab-0.20.0.dist-info}/METADATA +38 -40
- {fotolab-0.18.4.dist-info → fotolab-0.20.0.dist-info}/RECORD +8 -8
- {fotolab-0.18.4.dist-info → fotolab-0.20.0.dist-info}/LICENSE.md +0 -0
- {fotolab-0.18.4.dist-info → fotolab-0.20.0.dist-info}/WHEEL +0 -0
- {fotolab-0.18.4.dist-info → fotolab-0.20.0.dist-info}/entry_points.txt +0 -0
fotolab/__init__.py
CHANGED
fotolab/auto.py
CHANGED
fotolab/resize.py
CHANGED
@@ -18,8 +18,9 @@
|
|
18
18
|
import argparse
|
19
19
|
import logging
|
20
20
|
import math
|
21
|
+
import sys
|
21
22
|
|
22
|
-
from PIL import Image
|
23
|
+
from PIL import Image, ImageColor
|
23
24
|
|
24
25
|
from fotolab import save_image
|
25
26
|
|
@@ -44,28 +45,69 @@ def build_subparser(subparsers) -> None:
|
|
44
45
|
metavar="IMAGE_FILENAMES",
|
45
46
|
)
|
46
47
|
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
"
|
52
|
-
dest="
|
53
|
-
help="
|
54
|
-
type=int,
|
55
|
-
default=DEFAULT_WIDTH,
|
56
|
-
metavar="WIDTH",
|
48
|
+
resize_parser.add_argument(
|
49
|
+
"-c",
|
50
|
+
"--canvas",
|
51
|
+
default=False,
|
52
|
+
action="store_true",
|
53
|
+
dest="canvas",
|
54
|
+
help="paste image onto a larger canvas",
|
57
55
|
)
|
58
56
|
|
59
|
-
|
60
|
-
"-
|
61
|
-
"--
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
57
|
+
resize_parser.add_argument(
|
58
|
+
"-l",
|
59
|
+
"--canvas-color",
|
60
|
+
default="black",
|
61
|
+
dest="canvas_color",
|
62
|
+
help=(
|
63
|
+
"the color of the extended larger canvas"
|
64
|
+
"(default: '%(default)s')"
|
65
|
+
),
|
67
66
|
)
|
68
67
|
|
68
|
+
if "-c" in sys.argv or "--canvas" in sys.argv:
|
69
|
+
resize_parser.add_argument(
|
70
|
+
"-W",
|
71
|
+
"--width",
|
72
|
+
dest="width",
|
73
|
+
help="set the width of the image (default: '%(default)s')",
|
74
|
+
type=int,
|
75
|
+
required=True,
|
76
|
+
metavar="WIDTH",
|
77
|
+
)
|
78
|
+
|
79
|
+
resize_parser.add_argument(
|
80
|
+
"-H",
|
81
|
+
"--height",
|
82
|
+
dest="height",
|
83
|
+
help="set the height of the image (default: '%(default)s')",
|
84
|
+
type=int,
|
85
|
+
required=True,
|
86
|
+
metavar="HEIGHT",
|
87
|
+
)
|
88
|
+
else:
|
89
|
+
group = resize_parser.add_mutually_exclusive_group(required=False)
|
90
|
+
|
91
|
+
group.add_argument(
|
92
|
+
"-W",
|
93
|
+
"--width",
|
94
|
+
dest="width",
|
95
|
+
help="set the width of the image (default: '%(default)s')",
|
96
|
+
type=int,
|
97
|
+
default=DEFAULT_WIDTH,
|
98
|
+
metavar="WIDTH",
|
99
|
+
)
|
100
|
+
|
101
|
+
group.add_argument(
|
102
|
+
"-H",
|
103
|
+
"--height",
|
104
|
+
dest="height",
|
105
|
+
help="set the height of the image (default: '%(default)s')",
|
106
|
+
type=int,
|
107
|
+
default=DEFAULT_HEIGHT,
|
108
|
+
metavar="HEIGHT",
|
109
|
+
)
|
110
|
+
|
69
111
|
|
70
112
|
def run(args: argparse.Namespace) -> None:
|
71
113
|
"""Run resize subcommand.
|
@@ -80,14 +122,32 @@ def run(args: argparse.Namespace) -> None:
|
|
80
122
|
|
81
123
|
for image_filename in args.image_filenames:
|
82
124
|
original_image = Image.open(image_filename)
|
125
|
+
if args.canvas:
|
126
|
+
resized_image = _resize_image_onto_canvas(original_image, args)
|
127
|
+
else:
|
128
|
+
resized_image = _resize_image(original_image, args)
|
129
|
+
save_image(args, resized_image, image_filename, "resize")
|
83
130
|
|
84
|
-
new_width, new_height = _calc_new_image_dimension(original_image, args)
|
85
|
-
resized_image = original_image.copy()
|
86
|
-
resized_image = resized_image.resize(
|
87
|
-
(new_width, new_height), Image.Resampling.LANCZOS
|
88
|
-
)
|
89
131
|
|
90
|
-
|
132
|
+
def _resize_image_onto_canvas(original_image, args):
|
133
|
+
resized_image = Image.new(
|
134
|
+
"RGB",
|
135
|
+
(args.width, args.height),
|
136
|
+
(*ImageColor.getrgb(args.canvas_color), 128),
|
137
|
+
)
|
138
|
+
x_offset = (args.width - original_image.width) // 2
|
139
|
+
y_offset = (args.height - original_image.height) // 2
|
140
|
+
resized_image.paste(original_image, (x_offset, y_offset))
|
141
|
+
return resized_image
|
142
|
+
|
143
|
+
|
144
|
+
def _resize_image(original_image, args):
|
145
|
+
new_width, new_height = _calc_new_image_dimension(original_image, args)
|
146
|
+
resized_image = original_image.copy()
|
147
|
+
resized_image = resized_image.resize(
|
148
|
+
(new_width, new_height), Image.Resampling.LANCZOS
|
149
|
+
)
|
150
|
+
return resized_image
|
91
151
|
|
92
152
|
|
93
153
|
def _calc_new_image_dimension(image, args) -> tuple:
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: fotolab
|
3
|
-
Version: 0.
|
3
|
+
Version: 0.20.0
|
4
4
|
Summary: A console program that manipulate images.
|
5
5
|
Keywords: photography,photo
|
6
6
|
Author-email: Kian-Meng Ang <kianmeng@cpan.org>
|
@@ -60,14 +60,13 @@ fotolab -h
|
|
60
60
|
|
61
61
|
```console
|
62
62
|
usage: fotolab [-h] [-o] [-op] [-od OUTPUT_DIR] [-q] [-v] [-d] [-V]
|
63
|
-
{animate,auto,border,contrast,info,resize,rotate,montage,sharpen,watermark,env}
|
64
|
-
...
|
63
|
+
{animate,auto,border,contrast,info,resize,rotate,montage,sharpen,watermark,env} ...
|
65
64
|
|
66
65
|
A console program to manipulate photos.
|
67
66
|
|
68
|
-
|
69
|
-
|
70
|
-
|
67
|
+
website: https://github.com/kianmeng/fotolab
|
68
|
+
changelog: https://github.com/kianmeng/fotolab/blob/master/CHANGELOG.md
|
69
|
+
issues: https://github.com/kianmeng/fotolab/issues
|
71
70
|
|
72
71
|
positional arguments:
|
73
72
|
{animate,auto,border,contrast,info,resize,rotate,montage,sharpen,watermark,env}
|
@@ -88,7 +87,7 @@ options:
|
|
88
87
|
-h, --help show this help message and exit
|
89
88
|
-o, --overwrite overwrite existing image
|
90
89
|
-op, --open open the image using default program (default: 'False')
|
91
|
-
-od
|
90
|
+
-od, --output-dir OUTPUT_DIR
|
92
91
|
set default output folder (default: 'output')
|
93
92
|
-q, --quiet suppress all logging
|
94
93
|
-v, --verbose show verbosity of debugging log, use -vv, -vvv for more details
|
@@ -115,11 +114,10 @@ positional arguments:
|
|
115
114
|
|
116
115
|
options:
|
117
116
|
-h, --help show this help message and exit
|
118
|
-
-f
|
119
|
-
|
120
|
-
-d DURATION, --duration DURATION
|
117
|
+
-f, --format FORMAT set the image format (default: 'gif')
|
118
|
+
-d, --duration DURATION
|
121
119
|
set the duration in milliseconds (default: '2500')
|
122
|
-
-l
|
120
|
+
-l, --loop LOOP set the loop cycle (default: '0')
|
123
121
|
```
|
124
122
|
|
125
123
|
<!--help-animate !-->
|
@@ -162,17 +160,15 @@ positional arguments:
|
|
162
160
|
|
163
161
|
options:
|
164
162
|
-h, --help show this help message and exit
|
165
|
-
-c
|
166
|
-
|
167
|
-
-
|
168
|
-
set the width of border (default: '10')
|
169
|
-
-wt WIDTH, --width-top WIDTH
|
163
|
+
-c, --color COLOR set the color of border (default: 'black')
|
164
|
+
-w, --width WIDTH set the width of border (default: '10')
|
165
|
+
-wt, --width-top WIDTH
|
170
166
|
set the width of top border (default: '0')
|
171
|
-
-wr
|
167
|
+
-wr, --width-right WIDTH
|
172
168
|
set the width of right border (default: '0')
|
173
|
-
-wb
|
169
|
+
-wb, --width-bottom WIDTH
|
174
170
|
set the width of bottom border (default: '0')
|
175
|
-
-wl
|
171
|
+
-wl, --width-left WIDTH
|
176
172
|
set the width of left border (default: '0')
|
177
173
|
```
|
178
174
|
|
@@ -190,13 +186,12 @@ fotolab contrast -h
|
|
190
186
|
usage: fotolab contrast [-h] [-c CUTOFF] IMAGE_FILENAMES [IMAGE_FILENAMES ...]
|
191
187
|
|
192
188
|
positional arguments:
|
193
|
-
IMAGE_FILENAMES
|
189
|
+
IMAGE_FILENAMES set the image filename
|
194
190
|
|
195
191
|
options:
|
196
|
-
-h, --help
|
197
|
-
-c
|
198
|
-
|
199
|
-
discard from histogram (default: '1')
|
192
|
+
-h, --help show this help message and exit
|
193
|
+
-c, --cutoff CUTOFF set the percentage of lightest or darkest pixels to
|
194
|
+
discard from histogram (default: '1')
|
200
195
|
```
|
201
196
|
|
202
197
|
<!--help-contrast !-->
|
@@ -271,7 +266,7 @@ fotolab resize -h
|
|
271
266
|
<!--help-resize !-->
|
272
267
|
|
273
268
|
```console
|
274
|
-
usage: fotolab resize [-h] [-
|
269
|
+
usage: fotolab resize [-h] [-c] [-l CANVAS_COLOR] [-W WIDTH | -H HEIGHT]
|
275
270
|
IMAGE_FILENAMES [IMAGE_FILENAMES ...]
|
276
271
|
|
277
272
|
positional arguments:
|
@@ -279,10 +274,12 @@ positional arguments:
|
|
279
274
|
|
280
275
|
options:
|
281
276
|
-h, --help show this help message and exit
|
282
|
-
-
|
283
|
-
|
284
|
-
|
285
|
-
|
277
|
+
-c, --canvas paste image onto a larger canvas
|
278
|
+
-l, --canvas-color CANVAS_COLOR
|
279
|
+
the color of the extended larger canvas(default:
|
280
|
+
'black')
|
281
|
+
-W, --width WIDTH set the width of the image (default: '600')
|
282
|
+
-H, --height HEIGHT set the height of the image (default: '277')
|
286
283
|
```
|
287
284
|
|
288
285
|
<!--help-resize !-->
|
@@ -304,12 +301,11 @@ positional arguments:
|
|
304
301
|
|
305
302
|
options:
|
306
303
|
-h, --help show this help message and exit
|
307
|
-
-r
|
308
|
-
|
309
|
-
-p PERCENT, --percent PERCENT
|
304
|
+
-r, --radius RADIUS set the radius or size of edges (default: '1')
|
305
|
+
-p, --percent PERCENT
|
310
306
|
set the amount of overall strength of sharpening
|
311
307
|
effect (default: '100')
|
312
|
-
-t
|
308
|
+
-t, --threshold THRESHOLD
|
313
309
|
set the minimum brightness changed to be sharpened
|
314
310
|
(default: '3')
|
315
311
|
```
|
@@ -329,6 +325,7 @@ usage: fotolab watermark [-h] [-t WATERMARK_TEXT]
|
|
329
325
|
[-p {top-left,top-right,bottom-left,bottom-right}]
|
330
326
|
[-pd PADDING] [-fs FONT_SIZE] [-fc FONT_COLOR]
|
331
327
|
[-ow OUTLINE_WIDTH] [-oc OUTLINE_COLOR] [--camera]
|
328
|
+
[-l]
|
332
329
|
IMAGE_FILENAMES [IMAGE_FILENAMES ...]
|
333
330
|
|
334
331
|
positional arguments:
|
@@ -336,26 +333,27 @@ positional arguments:
|
|
336
333
|
|
337
334
|
options:
|
338
335
|
-h, --help show this help message and exit
|
339
|
-
-t
|
336
|
+
-t, --text WATERMARK_TEXT
|
340
337
|
set the watermark text (default: 'kianmeng.org')
|
341
|
-
-p
|
338
|
+
-p, --position {top-left,top-right,bottom-left,bottom-right}
|
342
339
|
set position of the watermark text (default: 'bottom-
|
343
340
|
left')
|
344
|
-
-pd
|
341
|
+
-pd, --padding PADDING
|
345
342
|
set the padding of the watermark text relative to the
|
346
343
|
image (default: '15')
|
347
|
-
-fs
|
344
|
+
-fs, --font-size FONT_SIZE
|
348
345
|
set the font size of watermark text (default: '12')
|
349
|
-
-fc
|
346
|
+
-fc, --font-color FONT_COLOR
|
350
347
|
set the font color of watermark text (default:
|
351
348
|
'white')
|
352
|
-
-ow
|
349
|
+
-ow, --outline-width OUTLINE_WIDTH
|
353
350
|
set the outline width of the watermark text (default:
|
354
351
|
'2')
|
355
|
-
-oc
|
352
|
+
-oc, --outline-color OUTLINE_COLOR
|
356
353
|
set the outline color of the watermark text (default:
|
357
354
|
'black')
|
358
355
|
--camera use camera metadata as watermark
|
356
|
+
-l, --lowercase lowercase the watermark text
|
359
357
|
```
|
360
358
|
|
361
359
|
<!--help-watermark !-->
|
@@ -1,19 +1,19 @@
|
|
1
|
-
fotolab/__init__.py,sha256=
|
1
|
+
fotolab/__init__.py,sha256=kzqXT6wNge8UafUzTa85ZAalhfHIlxqmxi_5tm2kG38,2061
|
2
2
|
fotolab/__main__.py,sha256=aboOURPs_snOXTEWYR0q8oq1UTY9e-NxCd1j33V0wHI,833
|
3
3
|
fotolab/animate.py,sha256=ejimhTozo9DN7BbqqcV4x8zLnanZRKq1pxBBFeOdr6Q,2967
|
4
|
-
fotolab/auto.py,sha256=
|
4
|
+
fotolab/auto.py,sha256=l_-Kf5V5Anvwz1QV1ET-42YsDWEeHf_okHkXWOycWAI,2295
|
5
5
|
fotolab/border.py,sha256=5ch2d7LVPhB2OFuuXSW5ci6Cn967CPDQu0qSfaO7uMg,3591
|
6
6
|
fotolab/cli.py,sha256=FBFSeMNqcOiJ6MuAcy0qUvc9cscdFUG946HlWZXBPtY,4984
|
7
7
|
fotolab/contrast.py,sha256=l7Bs5p8W8ypN9Cg3fFHnU-A20UwMKtjTiPk6D0PRwpM,2095
|
8
8
|
fotolab/env.py,sha256=fzUoRWgYEiYJIWYEiiSLEb7dH_xVUOnhMpQgc1yjrTY,1457
|
9
9
|
fotolab/info.py,sha256=kbKMIqdkK-Wn2lWLvnFL_Efc45K9KCaR_euTv9LIGzw,2256
|
10
10
|
fotolab/montage.py,sha256=lUVY-zDSH7mwH-s34_XefdNp7CoDJHkwpbTUGiyJGgs,2037
|
11
|
-
fotolab/resize.py,sha256=
|
11
|
+
fotolab/resize.py,sha256=2bH1Kgoe_DqU8ozJ1E_oA6a9JPtuwIlo5a4sq_4Yles,5018
|
12
12
|
fotolab/rotate.py,sha256=l_vQgf0IcI8AR1TSVsk4PrMZtJ3j_wpU77rKiGJ-KTA,1715
|
13
13
|
fotolab/sharpen.py,sha256=wUPtJdtB6mCRmcHrA0CoEVO0O0ROBJWhejTvUeL67QU,2655
|
14
14
|
fotolab/watermark.py,sha256=zxmTT1k78tdqqzbRu13YVOFQ0Z1cKd7JHU4M0nV01DU,7418
|
15
|
-
fotolab-0.
|
16
|
-
fotolab-0.
|
17
|
-
fotolab-0.
|
18
|
-
fotolab-0.
|
19
|
-
fotolab-0.
|
15
|
+
fotolab-0.20.0.dist-info/entry_points.txt,sha256=mvw7AY_yZkIyjAxPtHNed9X99NZeLnMxEeAfEJUbrCM,44
|
16
|
+
fotolab-0.20.0.dist-info/LICENSE.md,sha256=tGtFDwxWTjuR9syrJoSv1Hiffd2u8Tu8cYClfrXS_YU,31956
|
17
|
+
fotolab-0.20.0.dist-info/WHEEL,sha256=Sgu64hAMa6g5FdzHxXv9Xdse9yxpGGMeagVtPMWpJQY,99
|
18
|
+
fotolab-0.20.0.dist-info/METADATA,sha256=IGoixqqnNPaX-faVwOGLClYzWTEZDZ-zoz1BZz3DZp8,10576
|
19
|
+
fotolab-0.20.0.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|