fotolab 0.13.0__py2.py3-none-any.whl → 0.14.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,7 +21,7 @@ import subprocess
21
21
  import sys
22
22
  from pathlib import Path
23
23
 
24
- __version__ = "0.13.0"
24
+ __version__ = "0.14.0"
25
25
 
26
26
  log = logging.getLogger(__name__)
27
27
 
fotolab/animate.py ADDED
@@ -0,0 +1,114 @@
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
+ """Animate subcommand."""
17
+
18
+ import argparse
19
+ import logging
20
+ from pathlib import Path
21
+
22
+ from PIL import Image
23
+
24
+ from fotolab import _open_image
25
+
26
+ log = logging.getLogger(__name__)
27
+
28
+
29
+ def build_subparser(subparsers) -> None:
30
+ """Build the subparser."""
31
+ animate_parser = subparsers.add_parser("animate", help="animate an image")
32
+
33
+ animate_parser.set_defaults(func=run)
34
+
35
+ animate_parser.add_argument(
36
+ dest="image_filenames",
37
+ help="set the image filenames",
38
+ nargs="+",
39
+ type=str,
40
+ default=None,
41
+ metavar="IMAGE_FILENAMES",
42
+ )
43
+
44
+ animate_parser.add_argument(
45
+ "-f",
46
+ "--format",
47
+ dest="format",
48
+ type=str,
49
+ choices=["gif", "webp"],
50
+ default="gif",
51
+ help="set the image format (default: '%(default)s')",
52
+ metavar="FORMAT",
53
+ )
54
+
55
+ animate_parser.add_argument(
56
+ "-d",
57
+ "--duration",
58
+ dest="duration",
59
+ type=int,
60
+ default=2500,
61
+ help="set the duration in milliseconds (default: '%(default)s')",
62
+ metavar="DURATION",
63
+ )
64
+
65
+ animate_parser.add_argument(
66
+ "-l",
67
+ "--loop",
68
+ dest="loop",
69
+ type=int,
70
+ default=0,
71
+ help="set the loop cycle (default: '%(default)s')",
72
+ metavar="LOOP",
73
+ )
74
+
75
+
76
+ def run(args: argparse.Namespace) -> None:
77
+ """Run animate subcommand.
78
+
79
+ Args:
80
+ config (argparse.Namespace): Config from command line arguments
81
+
82
+ Returns:
83
+ None
84
+ """
85
+ log.debug(args)
86
+
87
+ first_image = args.image_filenames[0]
88
+ animated_image = Image.open(first_image)
89
+
90
+ append_images = []
91
+ for image_filename in args.image_filenames[1:]:
92
+ append_images.append(Image.open(image_filename))
93
+
94
+ image_file = Path(first_image)
95
+ new_filename = Path(
96
+ args.output_dir,
97
+ image_file.with_name(f"animate_{image_file.stem}.{args.format}"),
98
+ )
99
+ new_filename.parent.mkdir(parents=True, exist_ok=True)
100
+
101
+ log.info("animate image: %s", new_filename)
102
+
103
+ animated_image.save(
104
+ new_filename,
105
+ format=args.format,
106
+ append_images=append_images,
107
+ save_all=True,
108
+ duration=args.duration,
109
+ loop=args.loop,
110
+ optimize=True,
111
+ )
112
+
113
+ if args.open:
114
+ _open_image(new_filename)
fotolab/cli.py CHANGED
@@ -25,6 +25,7 @@ import logging
25
25
  import sys
26
26
  from typing import Dict, Optional, Sequence
27
27
 
28
+ import fotolab.animate
28
29
  import fotolab.auto
29
30
  import fotolab.border
30
31
  import fotolab.contrast
@@ -121,6 +122,7 @@ def build_parser() -> argparse.ArgumentParser:
121
122
  )
122
123
 
123
124
  subparsers = parser.add_subparsers(help="sub-command help")
125
+ fotolab.animate.build_subparser(subparsers)
124
126
  fotolab.auto.build_subparser(subparsers)
125
127
  fotolab.border.build_subparser(subparsers)
126
128
  fotolab.contrast.build_subparser(subparsers)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: fotolab
3
- Version: 0.13.0
3
+ Version: 0.14.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,8 +57,9 @@ fotolab -h
57
57
  ```
58
58
 
59
59
  ```console
60
+
60
61
  usage: fotolab [-h] [-o] [-op] [-od OUTPUT_DIR] [-q] [-d] [-V]
61
- {auto,border,contrast,info,resize,montage,sharpen,watermark,env}
62
+ {animate,auto,border,contrast,info,resize,montage,sharpen,watermark,env}
62
63
  ...
63
64
 
64
65
  A console program to manipulate photos.
@@ -68,8 +69,9 @@ A console program to manipulate photos.
68
69
  issues: https://github.com/kianmeng/fotolab/issues
69
70
 
70
71
  positional arguments:
71
- {auto,border,contrast,info,resize,montage,sharpen,watermark,env}
72
+ {animate,auto,border,contrast,info,resize,montage,sharpen,watermark,env}
72
73
  sub-command help
74
+ animate animate an image
73
75
  auto auto adjust (resize, contrast, and watermark) a photo
74
76
  border add border to image
75
77
  contrast contrast an image
@@ -91,6 +93,29 @@ optional arguments:
91
93
  -V, --version show program's version number and exit
92
94
  ```
93
95
 
96
+ ### fotolab animate
97
+
98
+ ```console
99
+ fotolab animate -h
100
+ ```
101
+
102
+ ```console
103
+
104
+ usage: fotolab animate [-h] [-f FORMAT] [-d DURATION] [-l LOOP]
105
+ IMAGE_FILENAMES [IMAGE_FILENAMES ...]
106
+
107
+ positional arguments:
108
+ IMAGE_FILENAMES set the image filenames
109
+
110
+ optional arguments:
111
+ -h, --help show this help message and exit
112
+ -f FORMAT, --format FORMAT
113
+ set the image format (default: 'gif')
114
+ -d DURATION, --duration DURATION
115
+ set the duration in milliseconds (default: '2500')
116
+ -l LOOP, --loop LOOP set the loop cycle (default: '0')
117
+ ```
118
+
94
119
  ### fotolab auto
95
120
 
96
121
  ```console
@@ -1,8 +1,9 @@
1
- fotolab/__init__.py,sha256=Z3guoQD823MHOmrtHNE9W0RnI6neYdRWNCv7QTxQb6s,2074
1
+ fotolab/__init__.py,sha256=cpDAMSgpSA1exqkB5BGL2OrPVQfTzxV8nOTS5iP0rUE,2074
2
2
  fotolab/__main__.py,sha256=aboOURPs_snOXTEWYR0q8oq1UTY9e-NxCd1j33V0wHI,833
3
+ fotolab/animate.py,sha256=ejimhTozo9DN7BbqqcV4x8zLnanZRKq1pxBBFeOdr6Q,2967
3
4
  fotolab/auto.py,sha256=1Toxe8pA_tq15g1-imMFuHf1L94Ac7EthPTu7E8SAzE,2217
4
5
  fotolab/border.py,sha256=5ch2d7LVPhB2OFuuXSW5ci6Cn967CPDQu0qSfaO7uMg,3591
5
- fotolab/cli.py,sha256=KoSDb752mewrtKE5wDs9icXF2McBVOKoEB98KYAV-jQ,4570
6
+ fotolab/cli.py,sha256=ZbXkftGAIrlcOgWju6KIeCBA8-EDVop2mkRN5f1Sa34,4641
6
7
  fotolab/contrast.py,sha256=l7Bs5p8W8ypN9Cg3fFHnU-A20UwMKtjTiPk6D0PRwpM,2095
7
8
  fotolab/env.py,sha256=NTTvfISWBBfIw5opWrUfg0BtkaAtdUtcISBAJC2gVUk,1449
8
9
  fotolab/info.py,sha256=DawXTQJiQDBwy0Ml5Ysk8MvKga3ikp_aIw73AR3LdZo,1687
@@ -10,8 +11,8 @@ fotolab/montage.py,sha256=lUVY-zDSH7mwH-s34_XefdNp7CoDJHkwpbTUGiyJGgs,2037
10
11
  fotolab/resize.py,sha256=y3JT2IZUOeWf4gjORtaJ_ZseklO2jG6XvR-d6EdhS0k,2242
11
12
  fotolab/sharpen.py,sha256=DsbIe4VU0Ty5oVzKnU70p9dMfhKr1i_UAQDimzAGX-Y,2655
12
13
  fotolab/watermark.py,sha256=6LeK5g6W7Gq5kpLinwqBCwFGCtp0Uz_hrqBE3BD_CEU,5210
13
- fotolab-0.13.0.dist-info/entry_points.txt,sha256=mvw7AY_yZkIyjAxPtHNed9X99NZeLnMxEeAfEJUbrCM,44
14
- fotolab-0.13.0.dist-info/LICENSE.md,sha256=tGtFDwxWTjuR9syrJoSv1Hiffd2u8Tu8cYClfrXS_YU,31956
15
- fotolab-0.13.0.dist-info/WHEEL,sha256=Sgu64hAMa6g5FdzHxXv9Xdse9yxpGGMeagVtPMWpJQY,99
16
- fotolab-0.13.0.dist-info/METADATA,sha256=v1RC94R2HI1BVbz7dyA3nAVuGso-OsRmDZQvrHnCfuU,9085
17
- fotolab-0.13.0.dist-info/RECORD,,
14
+ fotolab-0.14.0.dist-info/entry_points.txt,sha256=mvw7AY_yZkIyjAxPtHNed9X99NZeLnMxEeAfEJUbrCM,44
15
+ fotolab-0.14.0.dist-info/LICENSE.md,sha256=tGtFDwxWTjuR9syrJoSv1Hiffd2u8Tu8cYClfrXS_YU,31956
16
+ fotolab-0.14.0.dist-info/WHEEL,sha256=Sgu64hAMa6g5FdzHxXv9Xdse9yxpGGMeagVtPMWpJQY,99
17
+ fotolab-0.14.0.dist-info/METADATA,sha256=jHoSNuIcWosz5li1NRXRTHRxpIFX3sjPv11jFAi7kMQ,9744
18
+ fotolab-0.14.0.dist-info/RECORD,,