fotolab 0.1.1__py2.py3-none-any.whl → 0.3.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
@@ -16,4 +16,4 @@
16
16
  """A console program that manipulate images."""
17
17
 
18
18
 
19
- __version__ = "0.1.1"
19
+ __version__ = "0.3.0"
fotolab/border.py ADDED
@@ -0,0 +1,54 @@
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
+ """Border subcommand."""
17
+
18
+ import argparse
19
+ import logging
20
+ from pathlib import Path
21
+
22
+ from PIL import Image, ImageColor, ImageOps
23
+
24
+ log = logging.getLogger(__name__)
25
+
26
+
27
+ def build_subparser(subparsers) -> None:
28
+ """Build the subparser."""
29
+ border_parser = subparsers.add_parser("border", help="add border to image")
30
+
31
+ border_parser.set_defaults(func=run)
32
+
33
+ border_parser.add_argument(
34
+ dest="image_filename",
35
+ help="set the image filename",
36
+ type=str,
37
+ default=None,
38
+ metavar="IMAGE_FILENAME",
39
+ )
40
+
41
+
42
+ def run(args: argparse.Namespace) -> None:
43
+ """Run border subcommand."""
44
+ log.debug(args)
45
+
46
+ image_file = Path(args.image_filename)
47
+
48
+ original_image = Image.open(args.image_filename)
49
+ bordered_image = original_image.copy()
50
+
51
+ ImageOps.expand(bordered_image, border=5, fill=ImageColor.getrgb("black"))
52
+
53
+ new_filename = image_file.with_name(f"border_{image_file.name}")
54
+ bordered_image.save(new_filename)
fotolab/cli.py CHANGED
@@ -25,6 +25,8 @@ import logging
25
25
  import sys
26
26
  from typing import Dict, Optional, Sequence
27
27
 
28
+ import fotolab.border
29
+ import fotolab.env
28
30
  import fotolab.watermark
29
31
  from fotolab import __version__
30
32
 
@@ -87,7 +89,9 @@ def build_parser() -> argparse.ArgumentParser:
87
89
  )
88
90
 
89
91
  subparsers = parser.add_subparsers(help="sub-command help")
92
+ fotolab.border.build_subparser(subparsers)
90
93
  fotolab.watermark.build_subparser(subparsers)
94
+ fotolab.env.build_subparser(subparsers)
91
95
 
92
96
  return parser
93
97
 
fotolab/env.py ADDED
@@ -0,0 +1,43 @@
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
+ """Env subcommand."""
17
+
18
+ import argparse
19
+ import logging
20
+ import platform
21
+ import sys
22
+
23
+ from fotolab import __version__
24
+
25
+ log = logging.getLogger(__name__)
26
+
27
+
28
+ def build_subparser(subparsers) -> None:
29
+ """Build the subparser."""
30
+ env_parser = subparsers.add_parser(
31
+ "env", help="print environment information for bug reporting"
32
+ )
33
+
34
+ env_parser.set_defaults(func=run)
35
+
36
+
37
+ def run(args: argparse.Namespace) -> None:
38
+ """Run env subcommand."""
39
+ log.debug(args)
40
+
41
+ print(f"fotolab: {__version__}")
42
+ print(f"python: {sys.version}")
43
+ print(f"platform: {platform.platform()}")
fotolab/watermark.py CHANGED
@@ -78,7 +78,7 @@ def build_subparser(subparsers) -> None:
78
78
  type=str,
79
79
  default="white",
80
80
  help="set the font color of watermark text (default: '%(default)s')",
81
- metavar="FONT_SIZE",
81
+ metavar="FONT_COLOR",
82
82
  )
83
83
 
84
84
  watermark_parser.add_argument(
@@ -109,7 +109,7 @@ def build_subparser(subparsers) -> None:
109
109
 
110
110
 
111
111
  def run(args: argparse.Namespace) -> None:
112
- """Run watermark sub-command."""
112
+ """Run watermark subcommand."""
113
113
  log.debug(args)
114
114
 
115
115
  image_file = Path(args.image_filename)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: fotolab
3
- Version: 0.1.1
3
+ Version: 0.3.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>
@@ -51,7 +51,8 @@ fotolab -h
51
51
  ```
52
52
 
53
53
  ```console
54
- usage: fotolab [-h] [-q] [-d] [-V] {watermark} ...
54
+
55
+ usage: fotolab [-h] [-q] [-d] [-V] {border,watermark,env} ...
55
56
 
56
57
  A console program to manipulate photos.
57
58
 
@@ -60,14 +61,33 @@ A console program to manipulate photos.
60
61
  issues: https://github.com/kianmeng/fotolab/issues
61
62
 
62
63
  positional arguments:
63
- {watermark} sub-command help
64
- watermark watermark an image
64
+ {border,watermark,env}
65
+ sub-command help
66
+ border add border to image
67
+ watermark watermark an image
68
+ env print environment information for bug reporting
65
69
 
66
70
  options:
67
- -h, --help show this help message and exit
68
- -q, --quiet suppress all logging
69
- -d, --debug show debugging log and stacktrace
70
- -V, --version show program's version number and exit
71
+ -h, --help show this help message and exit
72
+ -q, --quiet suppress all logging
73
+ -d, --debug show debugging log and stacktrace
74
+ -V, --version show program's version number and exit
75
+ ```
76
+
77
+ ### fotolab border
78
+
79
+ ```console
80
+ fotolab border -h
81
+ ```
82
+
83
+ ```console
84
+ usage: fotolab border [-h] IMAGE_FILENAME
85
+
86
+ positional arguments:
87
+ IMAGE_FILENAME set the image filename
88
+
89
+ options:
90
+ -h, --help show this help message and exit
71
91
  ```
72
92
 
73
93
  ### fotolab watermark
@@ -106,6 +126,19 @@ options:
106
126
  'black')
107
127
  ```
108
128
 
129
+ ### fotolab env
130
+
131
+ ```console
132
+ fotolab env -h
133
+ ```
134
+
135
+ ```console
136
+ usage: fotolab env [-h]
137
+
138
+ options:
139
+ -h, --help show this help message and exit
140
+ ```
141
+
109
142
  ## Copyright and License
110
143
 
111
144
  Copyright (C) 2024 Kian-Meng Ang
@@ -0,0 +1,11 @@
1
+ fotolab/__init__.py,sha256=AwI4bRiHBa13gQtV77Wx67qDBiG_AuHZX8lh1gGd_fQ,764
2
+ fotolab/__main__.py,sha256=aboOURPs_snOXTEWYR0q8oq1UTY9e-NxCd1j33V0wHI,833
3
+ fotolab/border.py,sha256=24H3d1iaADrkPq3vy1NRZZE6T_9Z2V7TkpNPz25LT9o,1660
4
+ fotolab/cli.py,sha256=EquHxB7hanS82YZFxBwMkKjtzKQTF2nuNzMzhVUONXg,3561
5
+ fotolab/env.py,sha256=l1e39BJduaAqkg2cmrpInDE9pXXODLsmoWmhrhFf9Sc,1285
6
+ fotolab/watermark.py,sha256=35QCGqNdjDlRWmXfgLy06VqtMac5XaHDHUmJ0nq8lXA,4642
7
+ fotolab-0.3.0.dist-info/entry_points.txt,sha256=mvw7AY_yZkIyjAxPtHNed9X99NZeLnMxEeAfEJUbrCM,44
8
+ fotolab-0.3.0.dist-info/LICENSE.md,sha256=tGtFDwxWTjuR9syrJoSv1Hiffd2u8Tu8cYClfrXS_YU,31956
9
+ fotolab-0.3.0.dist-info/WHEEL,sha256=Sgu64hAMa6g5FdzHxXv9Xdse9yxpGGMeagVtPMWpJQY,99
10
+ fotolab-0.3.0.dist-info/METADATA,sha256=R3qFRJ4sPkeWR67DTvi0C0qTa1JKYaEcbMbLZHBrJkg,4847
11
+ fotolab-0.3.0.dist-info/RECORD,,
@@ -1,9 +0,0 @@
1
- fotolab/__init__.py,sha256=57QsTLueleEa0GTREbf9O-GihfDlKKvWOGZ78M0hYuY,764
2
- fotolab/__main__.py,sha256=aboOURPs_snOXTEWYR0q8oq1UTY9e-NxCd1j33V0wHI,833
3
- fotolab/cli.py,sha256=xVVd82kj83RrQoc6sFbM6Re2btG8ONWsLs5XrqsE27o,3429
4
- fotolab/watermark.py,sha256=feC6daf3MdFNq9H1IlADy1KfM3LrbW_IReNMgtCWPKg,4642
5
- fotolab-0.1.1.dist-info/entry_points.txt,sha256=mvw7AY_yZkIyjAxPtHNed9X99NZeLnMxEeAfEJUbrCM,44
6
- fotolab-0.1.1.dist-info/LICENSE.md,sha256=tGtFDwxWTjuR9syrJoSv1Hiffd2u8Tu8cYClfrXS_YU,31956
7
- fotolab-0.1.1.dist-info/WHEEL,sha256=Sgu64hAMa6g5FdzHxXv9Xdse9yxpGGMeagVtPMWpJQY,99
8
- fotolab-0.1.1.dist-info/METADATA,sha256=a-xlY3aRkJ6eJQD_iBgsOh0GQEscbdB4Q4KQMOasMj0,4320
9
- fotolab-0.1.1.dist-info/RECORD,,