fotolab 0.22.1__py3-none-any.whl → 0.23.0__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.22.1"
24
+ __version__ = "0.23.0"
25
25
 
26
26
  log = logging.getLogger(__name__)
27
27
 
fotolab/cli.py CHANGED
@@ -32,26 +32,31 @@ log = logging.getLogger(__name__)
32
32
 
33
33
 
34
34
  def setup_logging(args: argparse.Namespace) -> None:
35
- """Set up logging by level."""
36
- if args.verbose == 0:
37
- logging.getLogger("PIL").setLevel(logging.ERROR)
35
+ """Sets up logging configuration based on command-line arguments.
38
36
 
37
+ Args:
38
+ args (argparse.Namespace): Namespace containing parsed arguments.
39
+ """
39
40
  if args.quiet:
40
41
  logging.disable(logging.NOTSET)
41
- else:
42
- level = logging.DEBUG if args.debug else logging.INFO
43
- format_string = (
44
- "[%(asctime)s] %(levelname)s: %(name)s: %(message)s"
45
- if args.debug
46
- else "%(message)s"
47
- )
42
+ return
48
43
 
49
- logging.basicConfig(
50
- level=level,
51
- format=format_string,
52
- stream=sys.stdout,
53
- datefmt="%Y-%m-%d %H:%M:%S",
54
- )
44
+ if args.verbose == 0:
45
+ logging.getLogger("PIL").setLevel(logging.ERROR)
46
+
47
+ level = logging.DEBUG if args.debug else logging.INFO
48
+ format_string = (
49
+ "[%(asctime)s] %(levelname)s: %(name)s: %(message)s"
50
+ if args.debug
51
+ else "%(message)s"
52
+ )
53
+
54
+ logging.basicConfig(
55
+ level=level,
56
+ format=format_string,
57
+ stream=sys.stdout,
58
+ datefmt="%Y-%m-%d %H:%M:%S",
59
+ )
55
60
 
56
61
 
57
62
  def build_parser() -> argparse.ArgumentParser:
@@ -40,6 +40,21 @@ def build_subparser(subparsers) -> None:
40
40
  metavar="IMAGE_FILENAMES",
41
41
  )
42
42
 
43
+ rotate_parser.add_argument(
44
+ "-r",
45
+ "--rotation",
46
+ type=int,
47
+ default=0,
48
+ help="Rotation angle in degrees (default: '%(default)s')",
49
+ )
50
+
51
+ rotate_parser.add_argument(
52
+ "-cw",
53
+ "--clockwise",
54
+ action="store_true",
55
+ help="Rotate clockwise (default: '%(default)s)",
56
+ )
57
+
43
58
 
44
59
  def run(args: argparse.Namespace) -> None:
45
60
  """Run rotate subcommand.
@@ -52,10 +67,14 @@ def run(args: argparse.Namespace) -> None:
52
67
  """
53
68
  log.debug(args)
54
69
 
70
+ rotation = args.rotation
71
+ if args.clockwise:
72
+ rotation = -rotation
73
+
55
74
  for image_filename in args.image_filenames:
56
75
  original_image = Image.open(image_filename)
57
76
  rotated_image = original_image.rotate(
58
- 180,
77
+ rotation,
59
78
  expand=True,
60
79
  )
61
80
  save_image(args, rotated_image, image_filename, "rotate")
@@ -237,19 +237,14 @@ def calc_padding(image, args) -> int:
237
237
 
238
238
  def calc_position(image, text_width, text_height, position, padding) -> tuple:
239
239
  """Calculate the boundary coordinates of the watermark text."""
240
- (position_x, position_y) = (0, 0)
241
-
242
- if position == "top-left":
243
- position_x = 0 + padding
244
- position_y = 0 + padding
245
- elif position == "top-right":
246
- position_x = image.width - text_width - padding
247
- position_y = 0 + padding
248
- elif position == "bottom-left":
249
- position_x = 0 + padding
250
- position_y = image.height - text_height - padding
251
- elif position == "bottom-right":
252
- position_x = image.width - text_width - padding
253
- position_y = image.height - text_height - padding
254
-
255
- return (position_x, position_y)
240
+ positions = {
241
+ "top-left": (padding, padding),
242
+ "top-right": (image.width - text_width - padding, padding),
243
+ "bottom-left": (padding, image.height - text_height - padding),
244
+ "bottom-right": (
245
+ image.width - text_width - padding,
246
+ image.height - text_height - padding,
247
+ ),
248
+ }
249
+
250
+ return positions.get(position, (0, 0))
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: fotolab
3
- Version: 0.22.1
3
+ Version: 0.23.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>
@@ -61,7 +61,7 @@ fotolab -h
61
61
 
62
62
  ```console
63
63
  usage: fotolab [-h] [-o] [-op] [-od OUTPUT_DIR] [-q] [-v] [-d] [-V]
64
- {animate,auto,border,contrast,info,resize,rotate,montage,sharpen,watermark,env} ...
64
+ {animate,auto,border,contrast,env,info,montage,resize,rotate,sharpen,watermark} ...
65
65
 
66
66
  A console program to manipulate photos.
67
67
 
@@ -70,19 +70,19 @@ changelog: https://github.com/kianmeng/fotolab/blob/master/CHANGELOG.md
70
70
  issues: https://github.com/kianmeng/fotolab/issues
71
71
 
72
72
  positional arguments:
73
- {animate,auto,border,contrast,info,resize,rotate,montage,sharpen,watermark,env}
73
+ {animate,auto,border,contrast,env,info,montage,resize,rotate,sharpen,watermark}
74
74
  sub-command help
75
75
  animate animate an image
76
76
  auto auto adjust (resize, contrast, and watermark) a photo
77
77
  border add border to image
78
78
  contrast contrast an image
79
+ env print environment information for bug reporting
79
80
  info info an image
81
+ montage montage a list of image
80
82
  resize resize an image
81
83
  rotate rotate an image
82
- montage montage a list of image
83
84
  sharpen sharpen an image
84
85
  watermark watermark an image
85
- env print environment information for bug reporting
86
86
 
87
87
  options:
88
88
  -h, --help show this help message and exit
@@ -206,7 +206,7 @@ fotolab info -h
206
206
  <!--help-info !-->
207
207
 
208
208
  ```console
209
- usage: fotolab info [-h] [-s] [--camera] IMAGE_FILENAME
209
+ usage: fotolab info [-h] [-s] [--camera] [--datetime] IMAGE_FILENAME
210
210
 
211
211
  positional arguments:
212
212
  IMAGE_FILENAME set the image filename
@@ -215,6 +215,7 @@ options:
215
215
  -h, --help show this help message and exit
216
216
  -s, --sort show image info by sorted field name
217
217
  --camera show the camera maker details
218
+ --datetime show the datetime
218
219
  ```
219
220
 
220
221
  <!--help-info !-->
@@ -228,13 +229,17 @@ fotolab rotate -h
228
229
  <!--help-rotate !-->
229
230
 
230
231
  ```console
231
- usage: fotolab rotate [-h] IMAGE_FILENAMES [IMAGE_FILENAMES ...]
232
+ usage: fotolab rotate [-h] [-r ROTATION] [-cw]
233
+ IMAGE_FILENAMES [IMAGE_FILENAMES ...]
232
234
 
233
235
  positional arguments:
234
- IMAGE_FILENAMES set the image filenames
236
+ IMAGE_FILENAMES set the image filenames
235
237
 
236
238
  options:
237
- -h, --help show this help message and exit
239
+ -h, --help show this help message and exit
240
+ -r, --rotation ROTATION
241
+ Rotation angle in degrees (default: '0')
242
+ -cw, --clockwise Rotate clockwise (default: 'False)
238
243
  ```
239
244
 
240
245
  <!--help-rotate !-->
@@ -1,6 +1,6 @@
1
- fotolab/__init__.py,sha256=xdrWwLKoyxvOtFkatJOEMd_hDaY3--OVKgHZh6wY0n8,2061
1
+ fotolab/__init__.py,sha256=kuoG8pds6QFs3Dr-rEOqncyEAq-1X7KN5yIR2TBcn90,2061
2
2
  fotolab/__main__.py,sha256=aboOURPs_snOXTEWYR0q8oq1UTY9e-NxCd1j33V0wHI,833
3
- fotolab/cli.py,sha256=L_N94EsPeM1Ev0B5iyVvt4HEo7JTBNdhLmGZhBRIDA4,4235
3
+ fotolab/cli.py,sha256=vUS7eVcwEy2CWn4g5wTujLXS_GAzug9Np7j8-sM6GHU,4321
4
4
  fotolab/subcommands/__init__.py,sha256=5ncuu_LxuWphjNohm32Z_lD0FmJPWrAynBzeza0lyCU,1124
5
5
  fotolab/subcommands/animate.py,sha256=ejimhTozo9DN7BbqqcV4x8zLnanZRKq1pxBBFeOdr6Q,2967
6
6
  fotolab/subcommands/auto.py,sha256=ljvC0Z88Dva18YHyn3auAjlvVHqGrxsky-HGXwaIMZo,2391
@@ -10,11 +10,11 @@ fotolab/subcommands/env.py,sha256=fzUoRWgYEiYJIWYEiiSLEb7dH_xVUOnhMpQgc1yjrTY,14
10
10
  fotolab/subcommands/info.py,sha256=bkB41ZB5BewUCvY5XBn21D1pOyLcTjsI10dseYEARfE,3354
11
11
  fotolab/subcommands/montage.py,sha256=lUVY-zDSH7mwH-s34_XefdNp7CoDJHkwpbTUGiyJGgs,2037
12
12
  fotolab/subcommands/resize.py,sha256=2bH1Kgoe_DqU8ozJ1E_oA6a9JPtuwIlo5a4sq_4Yles,5018
13
- fotolab/subcommands/rotate.py,sha256=l_vQgf0IcI8AR1TSVsk4PrMZtJ3j_wpU77rKiGJ-KTA,1715
13
+ fotolab/subcommands/rotate.py,sha256=27Xrc8iV9n8WI6tOE-vBBMUeSYu2CtZAh-PGcF7JL-k,2144
14
14
  fotolab/subcommands/sharpen.py,sha256=wUPtJdtB6mCRmcHrA0CoEVO0O0ROBJWhejTvUeL67QU,2655
15
- fotolab/subcommands/watermark.py,sha256=tUqZoGjZk_7XG8qo7OiedfgmDY08qAWRF1Gx2ihAHO0,7264
16
- fotolab-0.22.1.dist-info/entry_points.txt,sha256=mvw7AY_yZkIyjAxPtHNed9X99NZeLnMxEeAfEJUbrCM,44
17
- fotolab-0.22.1.dist-info/LICENSE.md,sha256=tGtFDwxWTjuR9syrJoSv1Hiffd2u8Tu8cYClfrXS_YU,31956
18
- fotolab-0.22.1.dist-info/WHEEL,sha256=EZbGkh7Ie4PoZfRQ8I0ZuP9VklN_TvcZ6DSE5Uar4z4,81
19
- fotolab-0.22.1.dist-info/METADATA,sha256=-KmtwWES6ulcPrR5TSgBxYBowTgOejyQ9Mg0aMb3k0c,10724
20
- fotolab-0.22.1.dist-info/RECORD,,
15
+ fotolab/subcommands/watermark.py,sha256=1-5gpVCHYd7myZtsPWrrwcubTFDBdDzFmth7TSfBAgM,7073
16
+ fotolab-0.23.0.dist-info/entry_points.txt,sha256=mvw7AY_yZkIyjAxPtHNed9X99NZeLnMxEeAfEJUbrCM,44
17
+ fotolab-0.23.0.dist-info/LICENSE.md,sha256=tGtFDwxWTjuR9syrJoSv1Hiffd2u8Tu8cYClfrXS_YU,31956
18
+ fotolab-0.23.0.dist-info/WHEEL,sha256=EZbGkh7Ie4PoZfRQ8I0ZuP9VklN_TvcZ6DSE5Uar4z4,81
19
+ fotolab-0.23.0.dist-info/METADATA,sha256=L0KRYDKyddFDqwFLtfYhkgI45P7JzVnVEaFnlMbY8Ms,10975
20
+ fotolab-0.23.0.dist-info/RECORD,,