fotolab 0.18.4__py2.py3-none-any.whl → 0.19.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 CHANGED
@@ -21,7 +21,7 @@ import subprocess
21
21
  import sys
22
22
  from pathlib import Path
23
23
 
24
- __version__ = "0.18.4"
24
+ __version__ = "0.19.0"
25
25
 
26
26
  log = logging.getLogger(__name__)
27
27
 
fotolab/auto.py CHANGED
@@ -68,6 +68,7 @@ def run(args: argparse.Namespace) -> None:
68
68
  "outline_color": "black",
69
69
  "padding": 15,
70
70
  "camera": False,
71
+ "canvas": False,
71
72
  "lowercase": False,
72
73
  }
73
74
  combined_args = argparse.Namespace(**vars(args), **extra_args)
fotolab/resize.py CHANGED
@@ -18,6 +18,7 @@
18
18
  import argparse
19
19
  import logging
20
20
  import math
21
+ import sys
21
22
 
22
23
  from PIL import Image
23
24
 
@@ -44,27 +45,57 @@ def build_subparser(subparsers) -> None:
44
45
  metavar="IMAGE_FILENAMES",
45
46
  )
46
47
 
47
- group = resize_parser.add_mutually_exclusive_group(required=False)
48
-
49
- group.add_argument(
50
- "-wh",
51
- "--width",
52
- dest="width",
53
- help="set the width of the image (default: '%(default)s')",
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
- group.add_argument(
60
- "-ht",
61
- "--height",
62
- dest="height",
63
- help="set the height of the image (default: '%(default)s')",
64
- type=int,
65
- default=DEFAULT_HEIGHT,
66
- metavar="HEIGHT",
67
- )
57
+ if "-c" in sys.argv or "--canvas" in sys.argv:
58
+ resize_parser.add_argument(
59
+ "-W",
60
+ "--width",
61
+ dest="width",
62
+ help="set the width of the image (default: '%(default)s')",
63
+ type=int,
64
+ required=True,
65
+ metavar="WIDTH",
66
+ )
67
+
68
+ resize_parser.add_argument(
69
+ "-H",
70
+ "--height",
71
+ dest="height",
72
+ help="set the height of the image (default: '%(default)s')",
73
+ type=int,
74
+ required=True,
75
+ metavar="HEIGHT",
76
+ )
77
+ else:
78
+ group = resize_parser.add_mutually_exclusive_group(required=False)
79
+
80
+ group.add_argument(
81
+ "-W",
82
+ "--width",
83
+ dest="width",
84
+ help="set the width of the image (default: '%(default)s')",
85
+ type=int,
86
+ default=DEFAULT_WIDTH,
87
+ metavar="WIDTH",
88
+ )
89
+
90
+ group.add_argument(
91
+ "-H",
92
+ "--height",
93
+ dest="height",
94
+ help="set the height of the image (default: '%(default)s')",
95
+ type=int,
96
+ default=DEFAULT_HEIGHT,
97
+ metavar="HEIGHT",
98
+ )
68
99
 
69
100
 
70
101
  def run(args: argparse.Namespace) -> None:
@@ -80,14 +111,28 @@ def run(args: argparse.Namespace) -> None:
80
111
 
81
112
  for image_filename in args.image_filenames:
82
113
  original_image = Image.open(image_filename)
114
+ if args.canvas:
115
+ resized_image = _resize_image_onto_canvas(original_image, args)
116
+ else:
117
+ resized_image = _resize_image(original_image, args)
118
+ save_image(args, resized_image, image_filename, "resize")
83
119
 
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
120
 
90
- save_image(args, resized_image, image_filename, "resize")
121
+ def _resize_image_onto_canvas(original_image, args):
122
+ resized_image = Image.new("RGB", (args.width, args.height), (0, 0, 0))
123
+ x_offset = (args.width - original_image.width) // 2
124
+ y_offset = (args.height - original_image.height) // 2
125
+ resized_image.paste(original_image, (x_offset, y_offset))
126
+ return resized_image
127
+
128
+
129
+ def _resize_image(original_image, args):
130
+ new_width, new_height = _calc_new_image_dimension(original_image, args)
131
+ resized_image = original_image.copy()
132
+ resized_image = resized_image.resize(
133
+ (new_width, new_height), Image.Resampling.LANCZOS
134
+ )
135
+ return resized_image
91
136
 
92
137
 
93
138
  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.18.4
3
+ Version: 0.19.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
- website: https://github.com/kianmeng/fotolab
69
- changelog: https://github.com/kianmeng/fotolab/blob/master/CHANGELOG.md
70
- issues: https://github.com/kianmeng/fotolab/issues
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 OUTPUT_DIR, --output-dir OUTPUT_DIR
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 FORMAT, --format FORMAT
119
- set the image format (default: 'gif')
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 LOOP, --loop LOOP set the loop cycle (default: '0')
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 COLOR, --color COLOR
166
- set the color of border (default: 'black')
167
- -w WIDTH, --width WIDTH
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 WIDTH, --width-right WIDTH
167
+ -wr, --width-right WIDTH
172
168
  set the width of right border (default: '0')
173
- -wb WIDTH, --width-bottom WIDTH
169
+ -wb, --width-bottom WIDTH
174
170
  set the width of bottom border (default: '0')
175
- -wl WIDTH, --width-left WIDTH
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 set the image filename
189
+ IMAGE_FILENAMES set the image filename
194
190
 
195
191
  options:
196
- -h, --help show this help message and exit
197
- -c CUTOFF, --cutoff CUTOFF
198
- set the percentage of lightest or darkest pixels to
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,18 +266,17 @@ fotolab resize -h
271
266
  <!--help-resize !-->
272
267
 
273
268
  ```console
274
- usage: fotolab resize [-h] [-wh WIDTH | -ht HEIGHT]
269
+ usage: fotolab resize [-h] [-c] [-W WIDTH | -H HEIGHT]
275
270
  IMAGE_FILENAMES [IMAGE_FILENAMES ...]
276
271
 
277
272
  positional arguments:
278
- IMAGE_FILENAMES set the image filename
273
+ IMAGE_FILENAMES set the image filename
279
274
 
280
275
  options:
281
- -h, --help show this help message and exit
282
- -wh WIDTH, --width WIDTH
283
- set the width of the image (default: '600')
284
- -ht HEIGHT, --height HEIGHT
285
- set the height of the image (default: '277')
276
+ -h, --help show this help message and exit
277
+ -c, --canvas paste image onto a larger canvas
278
+ -W, --width WIDTH set the width of the image (default: '600')
279
+ -H, --height HEIGHT set the height of the image (default: '277')
286
280
  ```
287
281
 
288
282
  <!--help-resize !-->
@@ -304,12 +298,11 @@ positional arguments:
304
298
 
305
299
  options:
306
300
  -h, --help show this help message and exit
307
- -r RADIUS, --radius RADIUS
308
- set the radius or size of edges (default: '1')
309
- -p PERCENT, --percent PERCENT
301
+ -r, --radius RADIUS set the radius or size of edges (default: '1')
302
+ -p, --percent PERCENT
310
303
  set the amount of overall strength of sharpening
311
304
  effect (default: '100')
312
- -t THRESHOLD, --threshold THRESHOLD
305
+ -t, --threshold THRESHOLD
313
306
  set the minimum brightness changed to be sharpened
314
307
  (default: '3')
315
308
  ```
@@ -329,6 +322,7 @@ usage: fotolab watermark [-h] [-t WATERMARK_TEXT]
329
322
  [-p {top-left,top-right,bottom-left,bottom-right}]
330
323
  [-pd PADDING] [-fs FONT_SIZE] [-fc FONT_COLOR]
331
324
  [-ow OUTLINE_WIDTH] [-oc OUTLINE_COLOR] [--camera]
325
+ [-l]
332
326
  IMAGE_FILENAMES [IMAGE_FILENAMES ...]
333
327
 
334
328
  positional arguments:
@@ -336,26 +330,27 @@ positional arguments:
336
330
 
337
331
  options:
338
332
  -h, --help show this help message and exit
339
- -t WATERMARK_TEXT, --text WATERMARK_TEXT
333
+ -t, --text WATERMARK_TEXT
340
334
  set the watermark text (default: 'kianmeng.org')
341
- -p {top-left,top-right,bottom-left,bottom-right}, --position {top-left,top-right,bottom-left,bottom-right}
335
+ -p, --position {top-left,top-right,bottom-left,bottom-right}
342
336
  set position of the watermark text (default: 'bottom-
343
337
  left')
344
- -pd PADDING, --padding PADDING
338
+ -pd, --padding PADDING
345
339
  set the padding of the watermark text relative to the
346
340
  image (default: '15')
347
- -fs FONT_SIZE, --font-size FONT_SIZE
341
+ -fs, --font-size FONT_SIZE
348
342
  set the font size of watermark text (default: '12')
349
- -fc FONT_COLOR, --font-color FONT_COLOR
343
+ -fc, --font-color FONT_COLOR
350
344
  set the font color of watermark text (default:
351
345
  'white')
352
- -ow OUTLINE_WIDTH, --outline-width OUTLINE_WIDTH
346
+ -ow, --outline-width OUTLINE_WIDTH
353
347
  set the outline width of the watermark text (default:
354
348
  '2')
355
- -oc OUTLINE_COLOR, --outline-color OUTLINE_COLOR
349
+ -oc, --outline-color OUTLINE_COLOR
356
350
  set the outline color of the watermark text (default:
357
351
  'black')
358
352
  --camera use camera metadata as watermark
353
+ -l, --lowercase lowercase the watermark text
359
354
  ```
360
355
 
361
356
  <!--help-watermark !-->
@@ -1,19 +1,19 @@
1
- fotolab/__init__.py,sha256=QfvhUv_TG0_NHbiDaoyO0xlAfhUMvTGH9pRgXQYVPMw,2061
1
+ fotolab/__init__.py,sha256=DkLszPjcAZc4E9biMoVs7ceegfjssCxpllLvNn3-ZQw,2061
2
2
  fotolab/__main__.py,sha256=aboOURPs_snOXTEWYR0q8oq1UTY9e-NxCd1j33V0wHI,833
3
3
  fotolab/animate.py,sha256=ejimhTozo9DN7BbqqcV4x8zLnanZRKq1pxBBFeOdr6Q,2967
4
- fotolab/auto.py,sha256=SmEEbTXFiP1BiqaAFxPNTcGguVSUbAmLbSuWf_LgsBY,2270
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=cvPfh4wUfydM23Do7VnP6Bx2EqMHKfYFYrpiNhyWzCU,3259
11
+ fotolab/resize.py,sha256=TLtYE7D0EHBTrDyaroRhozL35KHfB5i6-CKRComxZlg,4688
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.18.4.dist-info/entry_points.txt,sha256=mvw7AY_yZkIyjAxPtHNed9X99NZeLnMxEeAfEJUbrCM,44
16
- fotolab-0.18.4.dist-info/LICENSE.md,sha256=tGtFDwxWTjuR9syrJoSv1Hiffd2u8Tu8cYClfrXS_YU,31956
17
- fotolab-0.18.4.dist-info/WHEEL,sha256=Sgu64hAMa6g5FdzHxXv9Xdse9yxpGGMeagVtPMWpJQY,99
18
- fotolab-0.18.4.dist-info/METADATA,sha256=7zF_Jtmba82SK9yip3IJFa9uH9_es80Y4NMon2f0MMw,10676
19
- fotolab-0.18.4.dist-info/RECORD,,
15
+ fotolab-0.19.0.dist-info/entry_points.txt,sha256=mvw7AY_yZkIyjAxPtHNed9X99NZeLnMxEeAfEJUbrCM,44
16
+ fotolab-0.19.0.dist-info/LICENSE.md,sha256=tGtFDwxWTjuR9syrJoSv1Hiffd2u8Tu8cYClfrXS_YU,31956
17
+ fotolab-0.19.0.dist-info/WHEEL,sha256=Sgu64hAMa6g5FdzHxXv9Xdse9yxpGGMeagVtPMWpJQY,99
18
+ fotolab-0.19.0.dist-info/METADATA,sha256=HegZzcmwt1UWLCul32i10IHQyD1qQLy38uwDHY8h-1k,10413
19
+ fotolab-0.19.0.dist-info/RECORD,,