fotolab 0.33.0__tar.gz → 0.33.2__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 (41) hide show
  1. {fotolab-0.33.0/src/fotolab.egg-info → fotolab-0.33.2}/PKG-INFO +2 -1
  2. {fotolab-0.33.0 → fotolab-0.33.2}/pyproject.toml +2 -1
  3. {fotolab-0.33.0 → fotolab-0.33.2}/src/fotolab/__init__.py +2 -18
  4. {fotolab-0.33.0 → fotolab-0.33.2}/src/fotolab/__main__.py +0 -1
  5. {fotolab-0.33.0 → fotolab-0.33.2}/src/fotolab/subcommands/resize.py +14 -14
  6. {fotolab-0.33.0 → fotolab-0.33.2/src/fotolab.egg-info}/PKG-INFO +2 -1
  7. {fotolab-0.33.0 → fotolab-0.33.2}/LICENSE.md +0 -0
  8. {fotolab-0.33.0 → fotolab-0.33.2}/README.md +0 -0
  9. {fotolab-0.33.0 → fotolab-0.33.2}/setup.cfg +0 -0
  10. {fotolab-0.33.0 → fotolab-0.33.2}/src/fotolab/cli.py +0 -0
  11. {fotolab-0.33.0 → fotolab-0.33.2}/src/fotolab/subcommands/__init__.py +0 -0
  12. {fotolab-0.33.0 → fotolab-0.33.2}/src/fotolab/subcommands/animate.py +0 -0
  13. {fotolab-0.33.0 → fotolab-0.33.2}/src/fotolab/subcommands/auto.py +0 -0
  14. {fotolab-0.33.0 → fotolab-0.33.2}/src/fotolab/subcommands/border.py +0 -0
  15. {fotolab-0.33.0 → fotolab-0.33.2}/src/fotolab/subcommands/contrast.py +0 -0
  16. {fotolab-0.33.0 → fotolab-0.33.2}/src/fotolab/subcommands/env.py +0 -0
  17. {fotolab-0.33.0 → fotolab-0.33.2}/src/fotolab/subcommands/halftone.py +0 -0
  18. {fotolab-0.33.0 → fotolab-0.33.2}/src/fotolab/subcommands/info.py +0 -0
  19. {fotolab-0.33.0 → fotolab-0.33.2}/src/fotolab/subcommands/montage.py +0 -0
  20. {fotolab-0.33.0 → fotolab-0.33.2}/src/fotolab/subcommands/rotate.py +0 -0
  21. {fotolab-0.33.0 → fotolab-0.33.2}/src/fotolab/subcommands/sharpen.py +0 -0
  22. {fotolab-0.33.0 → fotolab-0.33.2}/src/fotolab/subcommands/watermark.py +0 -0
  23. {fotolab-0.33.0 → fotolab-0.33.2}/src/fotolab.egg-info/SOURCES.txt +0 -0
  24. {fotolab-0.33.0 → fotolab-0.33.2}/src/fotolab.egg-info/dependency_links.txt +0 -0
  25. {fotolab-0.33.0 → fotolab-0.33.2}/src/fotolab.egg-info/entry_points.txt +0 -0
  26. {fotolab-0.33.0 → fotolab-0.33.2}/src/fotolab.egg-info/requires.txt +0 -0
  27. {fotolab-0.33.0 → fotolab-0.33.2}/src/fotolab.egg-info/top_level.txt +0 -0
  28. {fotolab-0.33.0 → fotolab-0.33.2}/tests/test_animate_subcommand.py +0 -0
  29. {fotolab-0.33.0 → fotolab-0.33.2}/tests/test_auto_subcommand.py +0 -0
  30. {fotolab-0.33.0 → fotolab-0.33.2}/tests/test_border_subcommand.py +0 -0
  31. {fotolab-0.33.0 → fotolab-0.33.2}/tests/test_contrast_subcommand.py +0 -0
  32. {fotolab-0.33.0 → fotolab-0.33.2}/tests/test_env_subcommand.py +0 -0
  33. {fotolab-0.33.0 → fotolab-0.33.2}/tests/test_halftone_subcommand.py +0 -0
  34. {fotolab-0.33.0 → fotolab-0.33.2}/tests/test_help_flag.py +0 -0
  35. {fotolab-0.33.0 → fotolab-0.33.2}/tests/test_info_subcommand.py +0 -0
  36. {fotolab-0.33.0 → fotolab-0.33.2}/tests/test_montage_subcommand.py +0 -0
  37. {fotolab-0.33.0 → fotolab-0.33.2}/tests/test_quiet_flag.py +0 -0
  38. {fotolab-0.33.0 → fotolab-0.33.2}/tests/test_resize_subcommand.py +0 -0
  39. {fotolab-0.33.0 → fotolab-0.33.2}/tests/test_rotate_subcommand.py +0 -0
  40. {fotolab-0.33.0 → fotolab-0.33.2}/tests/test_sharpen_subcommand.py +0 -0
  41. {fotolab-0.33.0 → fotolab-0.33.2}/tests/test_watermark_subcommand.py +0 -0
@@ -1,6 +1,7 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: fotolab
3
- Version: 0.33.0
3
+ Version: 0.33.2
4
+ Summary: A console program to manipulate photos.
4
5
  Author-email: Kian-Meng Ang <kianmeng@cpan.org>
5
6
  License-Expression: AGPL-3.0-or-later
6
7
  Project-URL: Changelog, https://github.com/kianmeng/fotolab/blob/master/CHANGELOG.md
@@ -7,7 +7,8 @@ where = ["src"]
7
7
 
8
8
  [project]
9
9
  name = "fotolab"
10
- version = "0.33.0"
10
+ version = "0.33.2"
11
+ description = "A console program to manipulate photos."
11
12
  authors = [{name = "Kian-Meng Ang", email = "kianmeng@cpan.org"}]
12
13
  requires-python = ">=3.9"
13
14
  readme = "README.md"
@@ -45,12 +45,10 @@ def save_gif_image(
45
45
  "loop": 0,
46
46
  "optimize": True,
47
47
  }
48
- _save_image_with_options(
49
- args, original_image, image_filepath, subcommand, **gif_kwargs
50
- )
48
+ save_image(args, original_image, image_filepath, subcommand, **gif_kwargs)
51
49
 
52
50
 
53
- def _save_image_with_options(
51
+ def save_image(
54
52
  args: argparse.Namespace,
55
53
  image: Image.Image,
56
54
  output_filepath: Path,
@@ -74,20 +72,6 @@ def _save_image_with_options(
74
72
  _open_image(new_filename)
75
73
 
76
74
 
77
- def save_image(
78
- args: argparse.Namespace,
79
- new_image: Image.Image,
80
- output_filepath: Path,
81
- subcommand: str,
82
- ) -> None:
83
- """Save image after image operation.
84
-
85
- Returns:
86
- None
87
- """
88
- _save_image_with_options(args, new_image, output_filepath, subcommand)
89
-
90
-
91
75
  def _get_output_filename(
92
76
  args: argparse.Namespace, image_file: Path, subcommand: str
93
77
  ) -> Path:
@@ -19,4 +19,3 @@ from fotolab.cli import main
19
19
 
20
20
  if __name__ == "__main__":
21
21
  main()
22
- raise SystemExit()
@@ -168,26 +168,26 @@ def _resize_image(original_image, args):
168
168
 
169
169
 
170
170
  def _calc_new_image_dimension(image, args) -> tuple:
171
- new_width = args.width
172
- new_height = args.height
173
-
174
171
  old_width, old_height = image.size
175
172
  log.debug("old image dimension: %d x %d", old_width, old_height)
176
173
 
177
- if args.width != DEFAULT_WIDTH:
178
- aspect_ratio = old_height / old_width
179
- log.debug("aspect ratio: %f", aspect_ratio)
174
+ new_width = args.width
175
+ new_height = args.height
180
176
 
181
- new_height = math.ceil(args.width * aspect_ratio)
182
- log.debug("new height: %d", new_height)
177
+ original_aspect_ratio = old_width / old_height
183
178
 
184
- if args.height != DEFAULT_HEIGHT:
185
- aspect_ratio = old_width / old_height
186
- log.debug("aspect ratio: %f", aspect_ratio)
179
+ if new_width != DEFAULT_WIDTH and new_height == DEFAULT_HEIGHT:
180
+ # user provided width, calculate height to maintain aspect ratio
181
+ new_height = math.ceil(new_width / original_aspect_ratio)
182
+ log.debug("new height calculated based on width: %d", new_height)
183
+ elif new_height != DEFAULT_HEIGHT and new_width == DEFAULT_WIDTH:
184
+ # user provided height, calculate width to maintain aspect ratio
185
+ new_width = math.ceil(new_height * original_aspect_ratio)
186
+ log.debug("new width calculated based on height: %d", new_width)
187
187
 
188
- new_width = math.floor(args.height * aspect_ratio)
189
- log.debug("new width: %d", new_width)
188
+ # if both are default, no calculation needed, use defaults
189
+ # due to argparse's mutually exclusive group, it's not possible for both
190
+ # new_width and new_height to be non-default when --canvas is False
190
191
 
191
192
  log.debug("new image dimension: %d x %d", new_width, new_height)
192
-
193
193
  return (new_width, new_height)
@@ -1,6 +1,7 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: fotolab
3
- Version: 0.33.0
3
+ Version: 0.33.2
4
+ Summary: A console program to manipulate photos.
4
5
  Author-email: Kian-Meng Ang <kianmeng@cpan.org>
5
6
  License-Expression: AGPL-3.0-or-later
6
7
  Project-URL: Changelog, https://github.com/kianmeng/fotolab/blob/master/CHANGELOG.md
File without changes
File without changes
File without changes
File without changes