fotolab 0.9.1__py2.py3-none-any.whl → 0.10.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,22 +21,22 @@ import subprocess
21
21
  import sys
22
22
  from pathlib import Path
23
23
 
24
- __version__ = "0.9.1"
24
+ __version__ = "0.10.0"
25
25
 
26
26
  log = logging.getLogger(__name__)
27
27
 
28
28
 
29
- def save_image(args, new_image):
30
- """Run resize subcommand.
29
+ def save_image(args, new_image, subcommand):
30
+ """Save image after image operation.
31
31
 
32
32
  Args:
33
33
  args (argparse.Namespace): Config from command line arguments
34
34
  new_image(PIL.Image.Image): Modified image
35
+ subcommand(str): Subcommand used to call this function
35
36
 
36
37
  Returns:
37
38
  None
38
39
  """
39
- action = args.func.__module__.split(".")[-1]
40
40
  image_file = Path(args.image_filename)
41
41
 
42
42
  if args.overwrite:
@@ -44,11 +44,11 @@ def save_image(args, new_image):
44
44
  else:
45
45
  new_filename = Path(
46
46
  args.output_dir,
47
- image_file.with_name(f"{action}_{image_file.name}"),
47
+ image_file.with_name(f"{subcommand}_{image_file.name}"),
48
48
  )
49
49
  new_filename.parent.mkdir(parents=True, exist_ok=True)
50
50
 
51
- log.info("%s image: %s", action, new_filename)
51
+ log.info("%s image: %s", subcommand, new_filename)
52
52
  new_image.save(new_filename)
53
53
 
54
54
  if args.open:
fotolab/border.py CHANGED
@@ -134,4 +134,4 @@ def run(args: argparse.Namespace) -> None:
134
134
  fill=ImageColor.getrgb(args.color),
135
135
  )
136
136
 
137
- save_image(args, bordered_image)
137
+ save_image(args, bordered_image, "border")
fotolab/cli.py CHANGED
@@ -29,6 +29,7 @@ import fotolab.auto
29
29
  import fotolab.border
30
30
  import fotolab.contrast
31
31
  import fotolab.env
32
+ import fotolab.info
32
33
  import fotolab.resize
33
34
  import fotolab.sharpen
34
35
  import fotolab.watermark
@@ -122,6 +123,7 @@ def build_parser() -> argparse.ArgumentParser:
122
123
  fotolab.auto.build_subparser(subparsers)
123
124
  fotolab.border.build_subparser(subparsers)
124
125
  fotolab.contrast.build_subparser(subparsers)
126
+ fotolab.info.build_subparser(subparsers)
125
127
  fotolab.resize.build_subparser(subparsers)
126
128
  fotolab.sharpen.build_subparser(subparsers)
127
129
  fotolab.watermark.build_subparser(subparsers)
fotolab/contrast.py CHANGED
@@ -70,4 +70,4 @@ def run(args: argparse.Namespace) -> None:
70
70
  original_image = Image.open(args.image_filename)
71
71
  contrast_image = ImageOps.autocontrast(original_image, cutoff=args.cutoff)
72
72
 
73
- save_image(args, contrast_image)
73
+ save_image(args, contrast_image, "contrast")
fotolab/info.py ADDED
@@ -0,0 +1,58 @@
1
+ # Copyright (C) 2024 Kian-Meng Ang
2
+ #
3
+ # This program is free software: you can redistribute it and/or modify it under
4
+ # the terms of the GNU Affero General Public License as published by the Free
5
+ # Software Foundation, either version 3 of the License, or (at your option) any
6
+ # later version.
7
+ #
8
+ # This program is distributed in the hope that it will be useful, but WITHOUT
9
+ # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
10
+ # FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
11
+ # details.
12
+ #
13
+ # You should have received a copy of the GNU Affero General Public License
14
+ # along with this program. If not, see <https://www.gnu.org/licenses/>.
15
+
16
+ """Info subcommand."""
17
+
18
+ import argparse
19
+ import logging
20
+
21
+ from PIL import ExifTags, Image
22
+
23
+ log = logging.getLogger(__name__)
24
+
25
+
26
+ def build_subparser(subparsers) -> None:
27
+ """Build the subparser."""
28
+ info_parser = subparsers.add_parser("info", help="info an image")
29
+
30
+ info_parser.set_defaults(func=run)
31
+
32
+ info_parser.add_argument(
33
+ dest="image_filename",
34
+ help="set the image filename",
35
+ type=str,
36
+ default=None,
37
+ metavar="IMAGE_FILENAME",
38
+ )
39
+
40
+
41
+ def run(args: argparse.Namespace) -> None:
42
+ """Run info subcommand.
43
+
44
+ Args:
45
+ config (argparse.Namespace): Config from command line arguments
46
+
47
+ Returns:
48
+ None
49
+ """
50
+ log.debug(args)
51
+
52
+ image = Image.open(args.image_filename)
53
+ exif = image._getexif()
54
+ info = {ExifTags.TAGS.get(tag_id): exif.get(tag_id) for tag_id in exif}
55
+
56
+ tag_name_width = max(map(len, info))
57
+ for tag_name, tag_value in info.items():
58
+ print(f"{tag_name:<{tag_name_width}}: {tag_value}")
fotolab/resize.py CHANGED
@@ -77,4 +77,4 @@ def run(args: argparse.Namespace) -> None:
77
77
  (args.width, args.height), Image.Resampling.LANCZOS
78
78
  )
79
79
 
80
- save_image(args, resized_image)
80
+ save_image(args, resized_image, "resize")
fotolab/sharpen.py CHANGED
@@ -93,4 +93,4 @@ def run(args: argparse.Namespace) -> None:
93
93
  args.radius, percent=args.percent, threshold=args.threshold
94
94
  )
95
95
  )
96
- save_image(args, sharpen_image)
96
+ save_image(args, sharpen_image, "sharpen")
fotolab/watermark.py CHANGED
@@ -145,7 +145,7 @@ def run(args: argparse.Namespace) -> None:
145
145
  stroke_fill=ImageColor.getrgb(args.outline_color),
146
146
  )
147
147
 
148
- save_image(args, watermarked_image)
148
+ save_image(args, watermarked_image, "watermark")
149
149
 
150
150
 
151
151
  def calculate_position(image, text_width, text_height, position) -> tuple:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: fotolab
3
- Version: 0.9.1
3
+ Version: 0.10.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>
@@ -57,9 +57,8 @@ fotolab -h
57
57
  ```
58
58
 
59
59
  ```console
60
-
61
60
  usage: fotolab [-h] [-o] [-op] [-od OUTPUT_DIR] [-q] [-d] [-V]
62
- {auto,border,contrast,resize,sharpen,watermark,env} ...
61
+ {auto,border,contrast,info,resize,sharpen,watermark,env} ...
63
62
 
64
63
  A console program to manipulate photos.
65
64
 
@@ -68,11 +67,12 @@ A console program to manipulate photos.
68
67
  issues: https://github.com/kianmeng/fotolab/issues
69
68
 
70
69
  positional arguments:
71
- {auto,border,contrast,resize,sharpen,watermark,env}
70
+ {auto,border,contrast,info,resize,sharpen,watermark,env}
72
71
  sub-command help
73
72
  auto auto adjust (resize, contrast, and watermark) a photo
74
73
  border add border to image
75
74
  contrast contrast an image
75
+ info info an image
76
76
  resize resize an image
77
77
  sharpen sharpen an image
78
78
  watermark watermark an image
@@ -135,6 +135,22 @@ optional arguments:
135
135
  -h, --help show this help message and exit
136
136
  ```
137
137
 
138
+ ### fotolab info
139
+
140
+ ```console
141
+ fotolab info -h
142
+ ```
143
+
144
+ ```console
145
+ usage: fotolab info [-h] IMAGE_FILENAME
146
+
147
+ positional arguments:
148
+ IMAGE_FILENAME set the image filename
149
+
150
+ optional arguments:
151
+ -h, --help show this help message and exit
152
+ ```
153
+
138
154
  ### fotolab sharpen
139
155
 
140
156
  ```console
@@ -0,0 +1,16 @@
1
+ fotolab/__init__.py,sha256=rLzpwtU7DbbHRYPQ4hQCyhQdg6OrvKeftKLf0PaytXo,2061
2
+ fotolab/__main__.py,sha256=aboOURPs_snOXTEWYR0q8oq1UTY9e-NxCd1j33V0wHI,833
3
+ fotolab/auto.py,sha256=k4DkHQp05m7UYUgHRrH9L1d0eSgOzrn2Cyk5BG27KyA,2173
4
+ fotolab/border.py,sha256=vujylADWHQsFwoCjoUa2yOIi8aJhTrVBgZsqyxDHKV0,3423
5
+ fotolab/cli.py,sha256=erXr3MXmMXQ9bDu9T6ZoOoRW0Yzt2z8anlSPJHkHtBk,4498
6
+ fotolab/contrast.py,sha256=82dpsFHW6kW7tR0kekFn1UoZAuAq3EXWQNOmrtRGw2g,1981
7
+ fotolab/env.py,sha256=NTTvfISWBBfIw5opWrUfg0BtkaAtdUtcISBAJC2gVUk,1449
8
+ fotolab/info.py,sha256=DawXTQJiQDBwy0Ml5Ysk8MvKga3ikp_aIw73AR3LdZo,1687
9
+ fotolab/resize.py,sha256=EkZYyWw9jHVmexIVbF3a9v5MYQEQxjVXlGGBMoB0IeQ,2138
10
+ fotolab/sharpen.py,sha256=DGeIq24JHpfftAF_h26cTMJVwSsxmnB9bL7lPkynuco,2546
11
+ fotolab/watermark.py,sha256=8qHkGzjw726pv8z8wY5dH70-7lnr9Zr-VXkZep3VSac,4661
12
+ fotolab-0.10.0.dist-info/entry_points.txt,sha256=mvw7AY_yZkIyjAxPtHNed9X99NZeLnMxEeAfEJUbrCM,44
13
+ fotolab-0.10.0.dist-info/LICENSE.md,sha256=tGtFDwxWTjuR9syrJoSv1Hiffd2u8Tu8cYClfrXS_YU,31956
14
+ fotolab-0.10.0.dist-info/WHEEL,sha256=Sgu64hAMa6g5FdzHxXv9Xdse9yxpGGMeagVtPMWpJQY,99
15
+ fotolab-0.10.0.dist-info/METADATA,sha256=SunRTn8v-nCy8Pw5N9qGLewPSyxyo9-t7On3RxCwHPI,6973
16
+ fotolab-0.10.0.dist-info/RECORD,,
@@ -1,15 +0,0 @@
1
- fotolab/__init__.py,sha256=3N1D57pcYWYmpOUqPIomNqEWg4qVTyVQP6AUvKRNGOg,2015
2
- fotolab/__main__.py,sha256=aboOURPs_snOXTEWYR0q8oq1UTY9e-NxCd1j33V0wHI,833
3
- fotolab/auto.py,sha256=k4DkHQp05m7UYUgHRrH9L1d0eSgOzrn2Cyk5BG27KyA,2173
4
- fotolab/border.py,sha256=-XNa118OpiXwCXptSCl1HdxTJ2SSnv62HSg6xfBChaY,3413
5
- fotolab/cli.py,sha256=4IEk0DRrCPIG0PB37f4zSyWUEbrZrLSKi5qJxb1M0Is,4433
6
- fotolab/contrast.py,sha256=chIjzw2h7TA_u63Y_ZNS_0otxtyXgHmHaCDOMUayS_A,1969
7
- fotolab/env.py,sha256=NTTvfISWBBfIw5opWrUfg0BtkaAtdUtcISBAJC2gVUk,1449
8
- fotolab/resize.py,sha256=6314jLmhwb_ktd6uKEToaNHW0ZOyPW2IiELosBsIcXs,2128
9
- fotolab/sharpen.py,sha256=5lLWZ2JOM-jfsqr6Lt9tlijZH1oz4KlvBytTL0-QLQI,2535
10
- fotolab/watermark.py,sha256=Hn3nUhQo3iFhvtlsLjGjFMGG8rqKFNGOYQBcwRS250M,4648
11
- fotolab-0.9.1.dist-info/entry_points.txt,sha256=mvw7AY_yZkIyjAxPtHNed9X99NZeLnMxEeAfEJUbrCM,44
12
- fotolab-0.9.1.dist-info/LICENSE.md,sha256=tGtFDwxWTjuR9syrJoSv1Hiffd2u8Tu8cYClfrXS_YU,31956
13
- fotolab-0.9.1.dist-info/WHEEL,sha256=Sgu64hAMa6g5FdzHxXv9Xdse9yxpGGMeagVtPMWpJQY,99
14
- fotolab-0.9.1.dist-info/METADATA,sha256=ukyF71SeL7LHXiYzH90aXgo6xzA94Q3aQ_iZjZDRr7s,6688
15
- fotolab-0.9.1.dist-info/RECORD,,