fotolab 0.26.0__py3-none-any.whl → 0.26.2__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
@@ -20,7 +20,7 @@ import subprocess
20
20
  import sys
21
21
  from pathlib import Path
22
22
 
23
- __version__ = "0.26.0"
23
+ __version__ = "0.26.2"
24
24
 
25
25
  log = logging.getLogger(__name__)
26
26
 
@@ -59,7 +59,7 @@ def _open_image(filename):
59
59
  platform_open_func = {
60
60
  "linux": subprocess.call(["xdg-open", filename]),
61
61
  "darwin": subprocess.call(["open", filename]),
62
- "windows": subprocess.Popen(["start", filename]),
62
+ "windows": subprocess.call(["start", filename]),
63
63
  }
64
64
  try:
65
65
  platform_open_func[sys.platform]
@@ -18,10 +18,11 @@
18
18
  import argparse
19
19
  import logging
20
20
  import math
21
+ from pathlib import Path
21
22
 
22
23
  from PIL import Image, ImageDraw
23
24
 
24
- from fotolab import save_image
25
+ from fotolab import _open_image, save_image
25
26
 
26
27
  log = logging.getLogger(__name__)
27
28
 
@@ -43,6 +44,15 @@ def build_subparser(subparsers) -> None:
43
44
  metavar="IMAGE_FILENAMES",
44
45
  )
45
46
 
47
+ halftone_parser.add_argument(
48
+ "-ba",
49
+ "--before-after",
50
+ default=False,
51
+ action="store_true",
52
+ dest="before_after",
53
+ help="generate a GIF showing before and after changes",
54
+ )
55
+
46
56
 
47
57
  def run(args: argparse.Namespace) -> None:
48
58
  """Run halftone subcommand.
@@ -90,4 +100,33 @@ def run(args: argparse.Namespace) -> None:
90
100
  [x - amp / 2, y - amp / 2, x + amp / 2, y + amp / 2], fill=255
91
101
  )
92
102
 
93
- save_image(args, halftone_image, image_filename, "halftone")
103
+ if args.before_after:
104
+ save_gif_image(
105
+ args, image_filename, original_image, halftone_image
106
+ )
107
+ else:
108
+ save_image(args, halftone_image, image_filename, "halftone")
109
+
110
+
111
+ def save_gif_image(args, image_filename, original_image, sharpen_image):
112
+ """Save the original and sharpen image."""
113
+ image_file = Path(image_filename)
114
+ new_filename = Path(
115
+ args.output_dir,
116
+ image_file.with_name(f"sharpen_gif_{image_file.stem}.gif"),
117
+ )
118
+ new_filename.parent.mkdir(parents=True, exist_ok=True)
119
+
120
+ log.info("sharpen gif image: %s", new_filename)
121
+ original_image.save(
122
+ new_filename,
123
+ format="gif",
124
+ append_images=[sharpen_image],
125
+ save_all=True,
126
+ duration=1000,
127
+ loop=0,
128
+ optimize=True,
129
+ )
130
+
131
+ if args.open:
132
+ _open_image(new_filename)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: fotolab
3
- Version: 0.26.0
3
+ Version: 0.26.2
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,env,info,montage,resize,rotate,sharpen,watermark} ...
64
+ {animate,auto,border,contrast,env,halftone,info,montage,resize,rotate,sharpen,watermark} ...
65
65
 
66
66
  A console program to manipulate photos.
67
67
 
@@ -70,13 +70,14 @@ 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,env,info,montage,resize,rotate,sharpen,watermark}
73
+ {animate,auto,border,contrast,env,halftone,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
79
  env print environment information for bug reporting
80
+ halftone halftone an image
80
81
  info info an image
81
82
  montage montage a list of image
82
83
  resize resize an image
@@ -1,4 +1,4 @@
1
- fotolab/__init__.py,sha256=FdS_YCS6GmyfP-phGNKZHFHmHb-2iPRgPDb-VNHm9DI,2173
1
+ fotolab/__init__.py,sha256=2TGdF54TWSQYHXY_fmt6aZG5R3jaaz_hrJMl2zmFf6g,2172
2
2
  fotolab/__main__.py,sha256=aboOURPs_snOXTEWYR0q8oq1UTY9e-NxCd1j33V0wHI,833
3
3
  fotolab/cli.py,sha256=9rhS-yhX1nE_zKBfR05QyEt-S7Y43mIP0yUQA6bsgV8,4326
4
4
  fotolab/subcommands/__init__.py,sha256=l3DlIaJ3u3jGjnC1H1yV8LZ_nPqOLJ6gikD4BCaMAQ0,1129
@@ -7,15 +7,15 @@ fotolab/subcommands/auto.py,sha256=p_e1f4mcrIFLqBXMNKvPQRDkNrAlK7FR6sdR5NAR0t8,2
7
7
  fotolab/subcommands/border.py,sha256=v5rdLb7Yq1kQI0MTSfVb0iroBroTV8oxOk-jMLB2who,3637
8
8
  fotolab/subcommands/contrast.py,sha256=8uPCd5xI-aUsL7rjdEPmfSskdzMwM-1tv0eRRONkW2M,2100
9
9
  fotolab/subcommands/env.py,sha256=JamU3a2xWPbwlAj5iThHs58KYkLmjpUphZfTQODBp_4,1471
10
- fotolab/subcommands/halftone.py,sha256=RNEdXqRbBK7-OnBJzVb1Jglr4uaq5RsgVCy9hDoo7S0,2748
10
+ fotolab/subcommands/halftone.py,sha256=u3O4vqaGbk1KqeuhQQy61Nij-_mEq083Spll6znRhY8,3820
11
11
  fotolab/subcommands/info.py,sha256=DANbfBNy2SzFfeE4KqOViAZkaME6xujfZvJTHIaZyCY,3312
12
12
  fotolab/subcommands/montage.py,sha256=hhRH9LsWxXa86_qtVDKGvk--Eap2nP17OTy81kq3Xjk,2048
13
13
  fotolab/subcommands/resize.py,sha256=d2Nlslzlvri9L2rqmE-HbmnLozylSk3U1Hi3DF1q3Mc,5023
14
14
  fotolab/subcommands/rotate.py,sha256=vhtiAD5r0i5humpjyAbkoxh2nQsSuBYUD-TgcECwUwE,2149
15
15
  fotolab/subcommands/sharpen.py,sha256=xz8RW8cRPM4eUvJTO1Stsur3G67DBftVGza8kF5j2Pc,3700
16
16
  fotolab/subcommands/watermark.py,sha256=zKIFMreqSRaTD89JPjtLZljfTw-5ZkbZNBAyLeFveGw,8905
17
- fotolab-0.26.0.dist-info/entry_points.txt,sha256=mvw7AY_yZkIyjAxPtHNed9X99NZeLnMxEeAfEJUbrCM,44
18
- fotolab-0.26.0.dist-info/LICENSE.md,sha256=tGtFDwxWTjuR9syrJoSv1Hiffd2u8Tu8cYClfrXS_YU,31956
19
- fotolab-0.26.0.dist-info/WHEEL,sha256=EZbGkh7Ie4PoZfRQ8I0ZuP9VklN_TvcZ6DSE5Uar4z4,81
20
- fotolab-0.26.0.dist-info/METADATA,sha256=CEe3EMlbCTfCuvSe_5MbbQueLiVl5XxI0NP2FTpfY3k,11058
21
- fotolab-0.26.0.dist-info/RECORD,,
17
+ fotolab-0.26.2.dist-info/entry_points.txt,sha256=mvw7AY_yZkIyjAxPtHNed9X99NZeLnMxEeAfEJUbrCM,44
18
+ fotolab-0.26.2.dist-info/LICENSE.md,sha256=tGtFDwxWTjuR9syrJoSv1Hiffd2u8Tu8cYClfrXS_YU,31956
19
+ fotolab-0.26.2.dist-info/WHEEL,sha256=EZbGkh7Ie4PoZfRQ8I0ZuP9VklN_TvcZ6DSE5Uar4z4,81
20
+ fotolab-0.26.2.dist-info/METADATA,sha256=eMKv2JU4gfe7rF4EzyGjOskJEEXgKgQ6F4FjC5MlTYw,11114
21
+ fotolab-0.26.2.dist-info/RECORD,,