fotolab 0.9.1__tar.gz → 0.10.0__tar.gz

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.
Files changed (38) hide show
  1. {fotolab-0.9.1 → fotolab-0.10.0}/.pre-commit-config.yaml +1 -1
  2. {fotolab-0.9.1 → fotolab-0.10.0}/CHANGELOG.md +17 -0
  3. {fotolab-0.9.1 → fotolab-0.10.0}/PKG-INFO +20 -4
  4. {fotolab-0.9.1 → fotolab-0.10.0}/Pipfile.lock +7 -7
  5. {fotolab-0.9.1 → fotolab-0.10.0}/README.md +19 -3
  6. {fotolab-0.9.1 → fotolab-0.10.0}/fotolab/__init__.py +6 -6
  7. {fotolab-0.9.1 → fotolab-0.10.0}/fotolab/border.py +1 -1
  8. {fotolab-0.9.1 → fotolab-0.10.0}/fotolab/cli.py +2 -0
  9. {fotolab-0.9.1 → fotolab-0.10.0}/fotolab/contrast.py +1 -1
  10. fotolab-0.10.0/fotolab/info.py +58 -0
  11. {fotolab-0.9.1 → fotolab-0.10.0}/fotolab/resize.py +1 -1
  12. {fotolab-0.9.1 → fotolab-0.10.0}/fotolab/sharpen.py +1 -1
  13. {fotolab-0.9.1 → fotolab-0.10.0}/fotolab/watermark.py +1 -1
  14. {fotolab-0.9.1 → fotolab-0.10.0}/.coveragerc +0 -0
  15. {fotolab-0.9.1 → fotolab-0.10.0}/.gitignore +0 -0
  16. {fotolab-0.9.1 → fotolab-0.10.0}/.python-version +0 -0
  17. {fotolab-0.9.1 → fotolab-0.10.0}/CONTRIBUTING.md +0 -0
  18. {fotolab-0.9.1 → fotolab-0.10.0}/LICENSE.md +0 -0
  19. {fotolab-0.9.1 → fotolab-0.10.0}/Pipfile +0 -0
  20. {fotolab-0.9.1 → fotolab-0.10.0}/docs/Makefile +0 -0
  21. {fotolab-0.9.1 → fotolab-0.10.0}/docs/make.bat +0 -0
  22. {fotolab-0.9.1 → fotolab-0.10.0}/docs/source/CHANGELOG.md +0 -0
  23. {fotolab-0.9.1 → fotolab-0.10.0}/docs/source/CONTRIBUTING.md +0 -0
  24. {fotolab-0.9.1 → fotolab-0.10.0}/docs/source/LICENSE.md +0 -0
  25. {fotolab-0.9.1 → fotolab-0.10.0}/docs/source/README.md +0 -0
  26. {fotolab-0.9.1 → fotolab-0.10.0}/docs/source/_static/logo.jpg +0 -0
  27. {fotolab-0.9.1 → fotolab-0.10.0}/docs/source/conf.py +0 -0
  28. {fotolab-0.9.1 → fotolab-0.10.0}/docs/source/index.rst +0 -0
  29. {fotolab-0.9.1 → fotolab-0.10.0}/fotolab/__main__.py +0 -0
  30. {fotolab-0.9.1 → fotolab-0.10.0}/fotolab/auto.py +0 -0
  31. {fotolab-0.9.1 → fotolab-0.10.0}/fotolab/env.py +0 -0
  32. {fotolab-0.9.1 → fotolab-0.10.0}/pyproject.toml +0 -0
  33. {fotolab-0.9.1 → fotolab-0.10.0}/tests/__init__.py +0 -0
  34. {fotolab-0.9.1 → fotolab-0.10.0}/tests/conftest.py +0 -0
  35. {fotolab-0.9.1 → fotolab-0.10.0}/tests/test_env.py +0 -0
  36. {fotolab-0.9.1 → fotolab-0.10.0}/tests/test_help_flag.py +0 -0
  37. {fotolab-0.9.1 → fotolab-0.10.0}/tests/test_quiet_flag.py +0 -0
  38. {fotolab-0.9.1 → fotolab-0.10.0}/tox.ini +0 -0
@@ -104,7 +104,7 @@ repos:
104
104
  - fotolab
105
105
  - tests
106
106
  - --unsafe-load-any-extension=y
107
- - --disable=R0801
107
+ - --disable=R0801,W0212
108
108
 
109
109
  - repo: https://github.com/pre-commit/mirrors-mypy
110
110
  rev: v1.9.0
@@ -7,6 +7,23 @@ and this project adheres to [0-based versioning](https://0ver.org/).
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## v0.10.0 (2024-03-31)
11
+
12
+ ### Added
13
+
14
+ - Add `info` subcommand to show EXIF data from image
15
+
16
+ ### Changed
17
+
18
+ - Bump deps
19
+ - Update help message in README
20
+ - Ignore `pylint` W0212 rule
21
+
22
+ ### Fix
23
+
24
+ - Fix incorrect action in log when running `auto` subcommand
25
+ - Update incorrect comment for `save_image` helper function
26
+
10
27
  ## v0.9.1 (2024-03-24)
11
28
 
12
29
  ### Changed
@@ -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
@@ -196,11 +196,11 @@
196
196
  },
197
197
  "filelock": {
198
198
  "hashes": [
199
- "sha256:521f5f56c50f8426f5e03ad3b281b490a87ef15bc6c526f168290f0c7148d44e",
200
- "sha256:57dbda9b35157b05fb3e58ee91448612eb674172fab98ee235ccb0b5bee19a1c"
199
+ "sha256:5ffa845303983e7a0b7ae17636509bc97997d58afeafa72fb141a17b152284cb",
200
+ "sha256:a79895a25bbefdf55d1a2a0a80968f7dbb28edcd6d4234a0afb3f37ecde4b546"
201
201
  ],
202
202
  "markers": "python_version >= '3.8'",
203
- "version": "==3.13.1"
203
+ "version": "==3.13.3"
204
204
  },
205
205
  "flake8": {
206
206
  "hashes": [
@@ -450,12 +450,12 @@
450
450
  },
451
451
  "pytest-cov": {
452
452
  "hashes": [
453
- "sha256:3904b13dfbfec47f003b8e77fd5b589cd11904a21ddf1ab38a64f204d6a10ef6",
454
- "sha256:6ba70b9e97e69fcc3fb45bfeab2d0a138fb65c4d0d6a41ef33983ad114be8c3a"
453
+ "sha256:4f0764a1219df53214206bf1feea4633c3b558a2925c8b59f144f682861ce652",
454
+ "sha256:5837b58e9f6ebd335b0f8060eecce69b662415b16dc503883a02f45dfeb14857"
455
455
  ],
456
456
  "index": "pypi",
457
- "markers": "python_version >= '3.7'",
458
- "version": "==4.1.0"
457
+ "markers": "python_version >= '3.8'",
458
+ "version": "==5.0.0"
459
459
  },
460
460
  "pytest-randomly": {
461
461
  "hashes": [
@@ -35,9 +35,8 @@ fotolab -h
35
35
  ```
36
36
 
37
37
  ```console
38
-
39
38
  usage: fotolab [-h] [-o] [-op] [-od OUTPUT_DIR] [-q] [-d] [-V]
40
- {auto,border,contrast,resize,sharpen,watermark,env} ...
39
+ {auto,border,contrast,info,resize,sharpen,watermark,env} ...
41
40
 
42
41
  A console program to manipulate photos.
43
42
 
@@ -46,11 +45,12 @@ A console program to manipulate photos.
46
45
  issues: https://github.com/kianmeng/fotolab/issues
47
46
 
48
47
  positional arguments:
49
- {auto,border,contrast,resize,sharpen,watermark,env}
48
+ {auto,border,contrast,info,resize,sharpen,watermark,env}
50
49
  sub-command help
51
50
  auto auto adjust (resize, contrast, and watermark) a photo
52
51
  border add border to image
53
52
  contrast contrast an image
53
+ info info an image
54
54
  resize resize an image
55
55
  sharpen sharpen an image
56
56
  watermark watermark an image
@@ -113,6 +113,22 @@ optional arguments:
113
113
  -h, --help show this help message and exit
114
114
  ```
115
115
 
116
+ ### fotolab info
117
+
118
+ ```console
119
+ fotolab info -h
120
+ ```
121
+
122
+ ```console
123
+ usage: fotolab info [-h] IMAGE_FILENAME
124
+
125
+ positional arguments:
126
+ IMAGE_FILENAME set the image filename
127
+
128
+ optional arguments:
129
+ -h, --help show this help message and exit
130
+ ```
131
+
116
132
  ### fotolab sharpen
117
133
 
118
134
  ```console
@@ -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:
@@ -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")
@@ -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)
@@ -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")
@@ -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}")
@@ -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")
@@ -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")
@@ -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:
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes