ascii-art-python 1.1.0__tar.gz → 1.2.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 (20) hide show
  1. {ascii_art_python-1.1.0/ascii_art_python.egg-info → ascii_art_python-1.2.0}/PKG-INFO +2 -1
  2. {ascii_art_python-1.1.0 → ascii_art_python-1.2.0}/ascii_art_python/__init__.py +1 -1
  3. {ascii_art_python-1.1.0 → ascii_art_python-1.2.0}/ascii_art_python/ascii_base.py +10 -8
  4. ascii_art_python-1.2.0/ascii_art_python/cli.py +101 -0
  5. {ascii_art_python-1.1.0 → ascii_art_python-1.2.0}/ascii_art_python/full_mode.py +3 -3
  6. {ascii_art_python-1.1.0 → ascii_art_python-1.2.0}/ascii_art_python/new_skool.py +3 -3
  7. {ascii_art_python-1.1.0 → ascii_art_python-1.2.0}/ascii_art_python/old_skool.py +1 -1
  8. {ascii_art_python-1.1.0 → ascii_art_python-1.2.0/ascii_art_python.egg-info}/PKG-INFO +2 -1
  9. {ascii_art_python-1.1.0 → ascii_art_python-1.2.0}/ascii_art_python.egg-info/SOURCES.txt +2 -0
  10. ascii_art_python-1.2.0/ascii_art_python.egg-info/entry_points.txt +3 -0
  11. {ascii_art_python-1.1.0 → ascii_art_python-1.2.0}/ascii_art_python.egg-info/requires.txt +1 -0
  12. {ascii_art_python-1.1.0 → ascii_art_python-1.2.0}/pyproject.toml +6 -1
  13. {ascii_art_python-1.1.0 → ascii_art_python-1.2.0}/LICENSE +0 -0
  14. {ascii_art_python-1.1.0 → ascii_art_python-1.2.0}/MANIFEST.in +0 -0
  15. {ascii_art_python-1.1.0 → ascii_art_python-1.2.0}/README.md +0 -0
  16. {ascii_art_python-1.1.0 → ascii_art_python-1.2.0}/ascii_art_python/assets/fonts/GoogleSansCode-Regular.ttf +0 -0
  17. {ascii_art_python-1.1.0 → ascii_art_python-1.2.0}/ascii_art_python/assets/fonts/KreativeSquareSM.ttf +0 -0
  18. {ascii_art_python-1.1.0 → ascii_art_python-1.2.0}/ascii_art_python.egg-info/dependency_links.txt +0 -0
  19. {ascii_art_python-1.1.0 → ascii_art_python-1.2.0}/ascii_art_python.egg-info/top_level.txt +0 -0
  20. {ascii_art_python-1.1.0 → ascii_art_python-1.2.0}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ascii_art_python
3
- Version: 1.1.0
3
+ Version: 1.2.0
4
4
  Summary: A Python library and CLI tool for converting images and videos into ASCII art.
5
5
  Author-email: Guillem Prieur <prieurguillem38@gmail.com>
6
6
  Project-URL: Homepage, https://gitlab.pprriieeuurr.fr/guill_prieur/ascii-art-python
@@ -31,6 +31,7 @@ Requires-Dist: tqdm>=4.65.0
31
31
  Requires-Dist: opencv-python-headless>=4.8.0
32
32
  Requires-Dist: moviepy>=2.0.0
33
33
  Requires-Dist: numpy>=1.24.0
34
+ Requires-Dist: click
34
35
  Requires-Dist: importlib_resources; python_version < "3.10"
35
36
  Dynamic: license-file
36
37
 
@@ -1,7 +1,7 @@
1
1
  """
2
2
  Module from https://gitlab.pprriieeuurr.fr/guill_prieur/ascii-art-python
3
3
  """
4
- __version__ = "1.1.0"
4
+ __version__ = "1.2.0"
5
5
  from . import new_skool
6
6
  from . import old_skool
7
7
  from . import full_mode
@@ -41,7 +41,7 @@ class Image(ABC):
41
41
  @property
42
42
  def ratio(self) -> float:
43
43
  """
44
- TODO
44
+ The compression ratio between the original image and the desired image.
45
45
  """
46
46
  return min(1.0, numpy.sqrt(
47
47
  self._max_len / (self._source_wb.width * self._source_wb.height)
@@ -50,7 +50,7 @@ class Image(ABC):
50
50
  @property
51
51
  def size(self) -> tuple[int, int]:
52
52
  """
53
- TODO
53
+ Dimensions (length, width) of the generated image.
54
54
  """
55
55
  return (
56
56
  int(self._source_wb.size[0] * self.ratio),
@@ -427,12 +427,14 @@ class Video:
427
427
  out.write(tab)
428
428
  out.release()
429
429
 
430
- if sound and quality:
431
- self.transfer_audio(self.path, filename + ".avi", filename + "_audio.avi")
432
- elif sound:
433
- self.transfer_audio(self.path, filename + ".mp4", filename + "_audio.mp4")
430
+ if sound:
431
+ print(" Adding audio...")
432
+ if quality:
433
+ self.transfer_audio(self.path, filename + ".avi", filename + "_audio.avi")
434
+ else:
435
+ self.transfer_audio(self.path, filename + ".mp4", filename + "_audio.mp4")
434
436
 
435
- def print_in_terminal(self) -> None:
437
+ def print_in_terminal(self, func_print: callable = print) -> None:
436
438
  """
437
439
  Plays the ASCII video animation by displaying it directly in the terminal.
438
440
 
@@ -446,5 +448,5 @@ class Video:
446
448
 
447
449
  for frame in self:
448
450
  time.sleep(max(next_sleep - time.time(), 0))
449
- print(frame.get_alternate_lines())
451
+ func_print(frame.get_alternate_lines())
450
452
  next_sleep += time_between
@@ -0,0 +1,101 @@
1
+ """
2
+ An ASCII art image in a style new-skool.
3
+ """
4
+ import mimetypes
5
+ import sys
6
+ import click
7
+ import ascii_art_python as aap
8
+
9
+
10
+ @click.command()
11
+ @click.argument("source_path", type=click.Path(exists=True))
12
+ @click.argument("target_filename", type=click.STRING)
13
+ @click.option("--length", "-l", default=15_000, help="The number of characters in the output")
14
+ @click.option("--mode", "-m", default="full_mode", help="full_mode / old_skool / new_skool")
15
+ def create_and_export(source_path, target_filename, length, mode):
16
+ """
17
+ Creates and exports an ASCII art image or video.
18
+ """
19
+ click.echo(f"▶ Converting '{source_path}'...")
20
+ click.echo(f"▶ Settings: length={length}, mode={mode}")
21
+
22
+ type_mime, _ = mimetypes.guess_type(source_path)
23
+
24
+ if type_mime is None:
25
+ click.secho("✗ Error: Unable to determine which export type to use")
26
+ sys.exit(1)
27
+ elif type_mime.startswith('image'):
28
+ click.echo("▶ Export type: image")
29
+ if mode == "full_mode":
30
+ image = aap.full_mode.Image.from_path(source_path, length)
31
+ elif mode == "old_skool":
32
+ image = aap.old_skool.Image.from_path(source_path, length)
33
+ elif mode == "new_skool":
34
+ image = aap.new_skool.Image.from_path(source_path, length)
35
+ else:
36
+ click.secho(f"✗ Error: Mode '{mode}' is not recognized.")
37
+ sys.exit(1)
38
+ image.export(target_filename)
39
+ click.echo("✓ Conversion complete!")
40
+ elif type_mime.startswith('video'):
41
+ click.echo("▶ Export type: video")
42
+ if mode == "full_mode":
43
+ video = aap.full_mode.Video(source_path, length, 10)
44
+ elif mode == "old_skool":
45
+ video = aap.old_skool.Video(source_path, length, 10)
46
+ elif mode == "new_skool":
47
+ video = aap.new_skool.Video(source_path, length, 10)
48
+ else:
49
+ click.secho(f"✗ Error: Mode '{mode}' is not recognized.")
50
+ sys.exit(1)
51
+ video.export(target_filename, sound=True)
52
+ click.echo("✓ Conversion complete!")
53
+ else:
54
+ click.secho("✗ Error: Unable to determine which export type to use")
55
+ sys.exit(1)
56
+
57
+ @click.command()
58
+ @click.argument("source_path", type=click.Path(exists=True))
59
+ @click.option("--length", "-l", default=3_000, help="The number of characters in the output")
60
+ @click.option("--mode", "-m", default="full_mode", help="full_mode / old_skool / new_skool")
61
+ def create_and_echo(source_path, length, mode):
62
+ """
63
+ Creates and prints an ASCII art image or video.
64
+ """
65
+ click.echo(f"▶ Converting '{source_path}'...")
66
+ click.echo(f"▶ Settings: length={length}, mode={mode}")
67
+
68
+ type_mime, _ = mimetypes.guess_type(source_path)
69
+
70
+ if type_mime is None:
71
+ click.secho("✗ Error: Unable to determine which export type to use")
72
+ sys.exit(1)
73
+ elif type_mime.startswith('image'):
74
+ click.echo("▶ Echo type: image")
75
+ if mode == "full_mode":
76
+ image = aap.full_mode.Image.from_path(source_path, length)
77
+ elif mode == "old_skool":
78
+ image = aap.old_skool.Image.from_path(source_path, length)
79
+ elif mode == "new_skool":
80
+ image = aap.new_skool.Image.from_path(source_path, length)
81
+ else:
82
+ click.secho(f"✗ Error: Mode '{mode}' is not recognized.")
83
+ sys.exit(1)
84
+ click.echo(image.get_alternate_lines())
85
+ click.echo("✓ Conversion complete!")
86
+ elif type_mime.startswith('video'):
87
+ click.echo("▶ Echo type: video")
88
+ if mode == "full_mode":
89
+ video = aap.full_mode.Video(source_path, length, 5)
90
+ elif mode == "old_skool":
91
+ video = aap.old_skool.Video(source_path, length, 5)
92
+ elif mode == "new_skool":
93
+ video = aap.new_skool.Video(source_path, length, 5)
94
+ else:
95
+ click.secho(f"✗ Error: Mode '{mode}' is not recognized.")
96
+ sys.exit(1)
97
+ video.print_in_terminal(click.echo)
98
+ click.echo("✓ Conversion complete!")
99
+ else:
100
+ click.secho("✗ Error: Unable to determine which export type to use")
101
+ sys.exit(1)
@@ -1,5 +1,5 @@
1
1
  """
2
- TODO
2
+ ASCII art tools in a style that blends old-skool and new-skool elements.
3
3
  """
4
4
  from typing import Union
5
5
  import PIL.Image
@@ -11,7 +11,7 @@ DEFAULT_GRID: list[str] = ["@", "$", "&", "#", "{", "*", "(", "=", ";", ":", "."
11
11
 
12
12
  class Image(ascii_base.Image):
13
13
  """
14
- TODO
14
+ An ASCII art image in a style that blends old-skool and new-skool elements.
15
15
  """
16
16
  def __init__(
17
17
  self,
@@ -54,7 +54,7 @@ class Image(ascii_base.Image):
54
54
 
55
55
  class Video(ascii_base.Video):
56
56
  """
57
- TODO
57
+ An ASCII art video in a style that blends old-skool and new-skool elements.
58
58
  """
59
59
  def __init__(self, path: str, frame_size: int = 12_000, fps: int = 10) -> None:
60
60
  super().__init__(path, Image, frame_size, fps)
@@ -1,5 +1,5 @@
1
1
  """
2
- TODO
2
+ ASCII art tools in a style new-skool.
3
3
  """
4
4
  from typing import Union
5
5
  import PIL.Image
@@ -9,7 +9,7 @@ DEFAULT_GRID: list[str] = ["@", "$", "&", "#", "{", "*", "(", "=", ";", ":", "."
9
9
 
10
10
  class Image(ascii_base.Image):
11
11
  """
12
- TODO
12
+ An ASCII art image in a style new-skool.
13
13
  """
14
14
  def __init__(
15
15
  self,
@@ -35,7 +35,7 @@ class Image(ascii_base.Image):
35
35
 
36
36
  class Video(ascii_base.Video):
37
37
  """
38
- TODO
38
+ An ASCII art video in a style new-skool.
39
39
  """
40
40
  def __init__(self, path: str, frame_size: int = 12_000, fps: int = 10):
41
41
  super().__init__(path, Image, frame_size, fps)
@@ -36,7 +36,7 @@ class Image(ascii_base.Image):
36
36
 
37
37
  class Video(ascii_base.Video):
38
38
  """
39
- TODO
39
+ An ASCII art video in a style old-skool.
40
40
  """
41
41
  def __init__(self, path: str, frame_size: int = 12_000, fps: int = 10):
42
42
  super().__init__(path, Image, frame_size, fps)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ascii_art_python
3
- Version: 1.1.0
3
+ Version: 1.2.0
4
4
  Summary: A Python library and CLI tool for converting images and videos into ASCII art.
5
5
  Author-email: Guillem Prieur <prieurguillem38@gmail.com>
6
6
  Project-URL: Homepage, https://gitlab.pprriieeuurr.fr/guill_prieur/ascii-art-python
@@ -31,6 +31,7 @@ Requires-Dist: tqdm>=4.65.0
31
31
  Requires-Dist: opencv-python-headless>=4.8.0
32
32
  Requires-Dist: moviepy>=2.0.0
33
33
  Requires-Dist: numpy>=1.24.0
34
+ Requires-Dist: click
34
35
  Requires-Dist: importlib_resources; python_version < "3.10"
35
36
  Dynamic: license-file
36
37
 
@@ -4,12 +4,14 @@ README.md
4
4
  pyproject.toml
5
5
  ascii_art_python/__init__.py
6
6
  ascii_art_python/ascii_base.py
7
+ ascii_art_python/cli.py
7
8
  ascii_art_python/full_mode.py
8
9
  ascii_art_python/new_skool.py
9
10
  ascii_art_python/old_skool.py
10
11
  ascii_art_python.egg-info/PKG-INFO
11
12
  ascii_art_python.egg-info/SOURCES.txt
12
13
  ascii_art_python.egg-info/dependency_links.txt
14
+ ascii_art_python.egg-info/entry_points.txt
13
15
  ascii_art_python.egg-info/requires.txt
14
16
  ascii_art_python.egg-info/top_level.txt
15
17
  ascii_art_python/assets/fonts/GoogleSansCode-Regular.ttf
@@ -0,0 +1,3 @@
1
+ [console_scripts]
2
+ aap-echo = ascii_art_python.cli:create_and_echo
3
+ aap-export = ascii_art_python.cli:create_and_export
@@ -3,6 +3,7 @@ tqdm>=4.65.0
3
3
  opencv-python-headless>=4.8.0
4
4
  moviepy>=2.0.0
5
5
  numpy>=1.24.0
6
+ click
6
7
 
7
8
  [:python_version < "3.10"]
8
9
  importlib_resources
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "ascii_art_python"
7
- version = "1.1.0"
7
+ version = "1.2.0"
8
8
  authors = [
9
9
  { name="Guillem Prieur", email="prieurguillem38@gmail.com" },
10
10
  ]
@@ -49,6 +49,7 @@ dependencies = [
49
49
  "opencv-python-headless>=4.8.0",
50
50
  "moviepy>=2.0.0",
51
51
  "numpy>=1.24.0",
52
+ "click",
52
53
  "importlib_resources; python_version < '3.10'",
53
54
  ]
54
55
 
@@ -56,3 +57,7 @@ dependencies = [
56
57
  "Homepage" = "https://gitlab.pprriieeuurr.fr/guill_prieur/ascii-art-python"
57
58
  "Bug Tracker" = "https://gitlab.pprriieeuurr.fr/guill_prieur/ascii-art-python/-/issues"
58
59
  "Source Code" = "https://gitlab.pprriieeuurr.fr/guill_prieur/ascii-art-python"
60
+
61
+ [project.scripts]
62
+ aap-export = "ascii_art_python.cli:create_and_export"
63
+ aap-echo = "ascii_art_python.cli:create_and_echo"