fotolab 0.28.1__py3-none-any.whl → 0.28.3__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
@@ -23,7 +23,7 @@ from pathlib import Path
23
23
 
24
24
  from PIL import Image
25
25
 
26
- __version__ = "0.28.1"
26
+ __version__ = "0.28.3"
27
27
 
28
28
  log = logging.getLogger(__name__)
29
29
 
@@ -102,5 +102,5 @@ def _open_image(filename):
102
102
  subprocess.Popen(["open", filename])
103
103
  log.info("open image: %s", filename.resolve())
104
104
 
105
- except OSError as e:
106
- log.error("Error opening image: %s -> %s", filename, e)
105
+ except OSError as error:
106
+ log.error("Error opening image: %s -> %s", filename, error)
@@ -17,6 +17,7 @@
17
17
 
18
18
  import argparse
19
19
  import logging
20
+ from typing import Tuple, Union
20
21
 
21
22
  from PIL import Image, ImageColor, ImageOps
22
23
 
@@ -54,9 +55,9 @@ def build_subparser(subparsers) -> None:
54
55
  "-w",
55
56
  "--width",
56
57
  dest="width",
57
- type=str,
58
+ type=int,
58
59
  default=10,
59
- help="set the width of border (default: '%(default)s')",
60
+ help="set the width of border in pixels (default: '%(default)s')",
60
61
  metavar="WIDTH",
61
62
  )
62
63
 
@@ -64,9 +65,9 @@ def build_subparser(subparsers) -> None:
64
65
  "-wt",
65
66
  "--width-top",
66
67
  dest="width_top",
67
- type=str,
68
+ type=int,
68
69
  default=0,
69
- help="set the width of top border (default: '%(default)s')",
70
+ help="set the width of top border in pixels (default: '%(default)s')",
70
71
  metavar="WIDTH",
71
72
  )
72
73
 
@@ -74,9 +75,12 @@ def build_subparser(subparsers) -> None:
74
75
  "-wr",
75
76
  "--width-right",
76
77
  dest="width_right",
77
- type=str,
78
+ type=int,
78
79
  default=0,
79
- help="set the width of right border (default: '%(default)s')",
80
+ help=(
81
+ "set the width of right border in pixels"
82
+ " (default: '%(default)s')"
83
+ ),
80
84
  metavar="WIDTH",
81
85
  )
82
86
 
@@ -84,9 +88,12 @@ def build_subparser(subparsers) -> None:
84
88
  "-wb",
85
89
  "--width-bottom",
86
90
  dest="width_bottom",
87
- type=str,
91
+ type=int,
88
92
  default=0,
89
- help="set the width of bottom border (default: '%(default)s')",
93
+ help=(
94
+ "set the width of bottom border in pixels"
95
+ " (default: '%(default)s')"
96
+ ),
90
97
  metavar="WIDTH",
91
98
  )
92
99
 
@@ -94,9 +101,9 @@ def build_subparser(subparsers) -> None:
94
101
  "-wl",
95
102
  "--width-left",
96
103
  dest="width_left",
97
- type=str,
104
+ type=int,
98
105
  default=0,
99
- help="set the width of left border (default: '%(default)s')",
106
+ help="set the width of left border in pixels (default: '%(default)s')",
100
107
  metavar="WIDTH",
101
108
  )
102
109
 
@@ -131,7 +138,6 @@ def run(args: argparse.Namespace) -> None:
131
138
 
132
139
  for image_filename in args.image_filenames:
133
140
  original_image = Image.open(image_filename)
134
-
135
141
  border = get_border(args)
136
142
  bordered_image = ImageOps.expand(
137
143
  original_image,
@@ -142,15 +148,19 @@ def run(args: argparse.Namespace) -> None:
142
148
  save_image(args, bordered_image, image_filename, "border")
143
149
 
144
150
 
145
- def get_border(args: argparse.Namespace) -> tuple[int, int, int, int]:
151
+ def get_border(
152
+ args: argparse.Namespace,
153
+ ) -> Union[Tuple[int, int, int, int], int]:
146
154
  """Calculate the border dimensions.
147
155
 
148
156
  Args:
149
157
  args (argparse.Namespace): Command line arguments
150
158
 
151
159
  Returns:
152
- tuple[int, int, int, int]: Border dimensions in pixesl. If individual
153
- widths are not specified, returns a uniform width for all sides.
160
+ Union[Tuple[int, int, int, int], int]: Border dimensions in pixels.
161
+ If individual widths are specified, returns a tuple of (left, top,
162
+ right, bottom) widths. Otherwise, returns a uniform width for all
163
+ sides.
154
164
  """
155
165
  if any(
156
166
  [
@@ -161,9 +171,9 @@ def get_border(args: argparse.Namespace) -> tuple[int, int, int, int]:
161
171
  ]
162
172
  ):
163
173
  return (
164
- int(args.width_left),
165
- int(args.width_top),
166
- int(args.width_right),
167
- int(args.width_bottom),
174
+ args.width_left,
175
+ args.width_top,
176
+ args.width_right,
177
+ args.width_bottom,
168
178
  )
169
179
  return args.width
@@ -86,14 +86,9 @@ def run(args: argparse.Namespace) -> None:
86
86
  log.debug(args)
87
87
 
88
88
  for image_filename in args.image_filenames:
89
- try:
90
- original_image = Image.open(image_filename)
91
- contrast_image = ImageOps.autocontrast(
92
- original_image, cutoff=args.cutoff
93
- )
94
-
95
- save_image(args, contrast_image, image_filename, "contrast")
96
- except FileNotFoundError:
97
- log.error(f"Image file not found: {image_filename}")
98
- except IOError:
99
- log.error(f"Cannot open or read image file: {image_filename}")
89
+ original_image = Image.open(image_filename)
90
+ contrast_image = ImageOps.autocontrast(
91
+ original_image, cutoff=args.cutoff
92
+ )
93
+
94
+ save_image(args, contrast_image, image_filename, "contrast")
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: fotolab
3
- Version: 0.28.1
3
+ Version: 0.28.3
4
4
  Summary: A console program that manipulate images.
5
5
  Keywords: photography,photo
6
6
  Author-email: Kian-Meng Ang <kianmeng@cpan.org>
@@ -1,11 +1,11 @@
1
- fotolab/__init__.py,sha256=2IDAKI99oReVMX9sl3GdQS_kEOdZBAa-rBuCKItjCYE,3239
1
+ fotolab/__init__.py,sha256=35eixAnDTMMD_Lo53GtOrbQP3TssQ5Ywex79dO-QwmU,3247
2
2
  fotolab/__main__.py,sha256=aboOURPs_snOXTEWYR0q8oq1UTY9e-NxCd1j33V0wHI,833
3
3
  fotolab/cli.py,sha256=fIApD9C4Vkn-u4CejOFTboSV5f-Ks9vBGxeb-_ca-Nw,3935
4
4
  fotolab/subcommands/__init__.py,sha256=l3DlIaJ3u3jGjnC1H1yV8LZ_nPqOLJ6gikD4BCaMAQ0,1129
5
5
  fotolab/subcommands/animate.py,sha256=OcS6Q6JM1TW6HF0dSgBsV9mpEGwDMcJlQssupkf0_ZA,3393
6
6
  fotolab/subcommands/auto.py,sha256=ia-xegV1Z4HvYsbKgmTzf1NfNFdTDPWfZe7vQ1_90Ik,2425
7
- fotolab/subcommands/border.py,sha256=zTRVnaifFcE8k_xEMhonbaiZaU_b1bDF2nBy8Hk0VXs,4360
8
- fotolab/subcommands/contrast.py,sha256=fkY_Xd405eifObGoqR4AsLSNriNBpkFjDR_pZ1AMqcc,2754
7
+ fotolab/subcommands/border.py,sha256=BS3BHytdWiNumxdKulKYK-WigbsKtPxECdvInUhUjSQ,4608
8
+ fotolab/subcommands/contrast.py,sha256=Z_YoCqtc3s5jhFq-30-46Nu_1P5o_8xDYRh5BDybK0g,2523
9
9
  fotolab/subcommands/env.py,sha256=QoxRvzZKgmoHTUxDV4QYhdChCpMWs5TbXFY_qIpIQpE,1469
10
10
  fotolab/subcommands/halftone.py,sha256=bRGG_Bg1T5ZV3UWsdMszOdPmc6g9_R0yNp5mb0g8hcE,4152
11
11
  fotolab/subcommands/info.py,sha256=Qp-Zu7Xp1ptLK211hOkFM5oxZWGTrlNBqCpbx2IjL9Y,3371
@@ -14,8 +14,8 @@ fotolab/subcommands/resize.py,sha256=UOb2rg_5ArRj0gxPTDOww_ix3tqJRC0W5b_S-Lt1G4w
14
14
  fotolab/subcommands/rotate.py,sha256=uBFjHyjiBSQLtrtH1p9myODIHUDr1gkL4PpU-6Y1Ofo,2575
15
15
  fotolab/subcommands/sharpen.py,sha256=YNho2IPbc-lPvSy3Bsjehc2JOEy27LPqFSGRULs9MyY,3492
16
16
  fotolab/subcommands/watermark.py,sha256=A_dUy_yf9wPHUexB9aIicFIS-BpWrjjfI8Hr4WCCBoc,9449
17
- fotolab-0.28.1.dist-info/entry_points.txt,sha256=mvw7AY_yZkIyjAxPtHNed9X99NZeLnMxEeAfEJUbrCM,44
18
- fotolab-0.28.1.dist-info/LICENSE.md,sha256=tGtFDwxWTjuR9syrJoSv1Hiffd2u8Tu8cYClfrXS_YU,31956
19
- fotolab-0.28.1.dist-info/WHEEL,sha256=EZbGkh7Ie4PoZfRQ8I0ZuP9VklN_TvcZ6DSE5Uar4z4,81
20
- fotolab-0.28.1.dist-info/METADATA,sha256=1gHE2Gk-XVzrNRzPhVQZew5Qr3oDY6gMNtj2hlPqpGE,12896
21
- fotolab-0.28.1.dist-info/RECORD,,
17
+ fotolab-0.28.3.dist-info/entry_points.txt,sha256=mvw7AY_yZkIyjAxPtHNed9X99NZeLnMxEeAfEJUbrCM,44
18
+ fotolab-0.28.3.dist-info/LICENSE.md,sha256=tGtFDwxWTjuR9syrJoSv1Hiffd2u8Tu8cYClfrXS_YU,31956
19
+ fotolab-0.28.3.dist-info/WHEEL,sha256=EZbGkh7Ie4PoZfRQ8I0ZuP9VklN_TvcZ6DSE5Uar4z4,81
20
+ fotolab-0.28.3.dist-info/METADATA,sha256=7aeKGIpjyjro2H-uHBnKIDd10eJ8rcqGLQUcAeVSDSo,12896
21
+ fotolab-0.28.3.dist-info/RECORD,,