Skip to content

Commit

Permalink
Add scaling support
Browse files Browse the repository at this point in the history
  • Loading branch information
aMarcireau committed Mar 30, 2023
1 parent 681f5ed commit ed68b32
Show file tree
Hide file tree
Showing 8 changed files with 49 additions and 8 deletions.
3 changes: 3 additions & 0 deletions charidotella/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,7 @@ def run_generators(configuration: dict[str, typing.Any]):
"timecode": True,
"h264_crf": 15,
"ffmpeg": "ffmpeg",
"scale": 1,
}
},
},
Expand All @@ -426,6 +427,7 @@ def run_generators(configuration: dict[str, typing.Any]):
"alpha": 0.1,
"png_compression_level": 6,
"background_color": "#191919",
"scale": 1,
},
},
{
Expand Down Expand Up @@ -479,6 +481,7 @@ def run_generators(configuration: dict[str, typing.Any]):
"cumulative_ratio": 0.01,
"timecode": False,
"ffmpeg": "ffmpeg",
"scale": 1,
},
},
]
Expand Down
9 changes: 8 additions & 1 deletion charidotella/tasks/colourtime.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import event_stream
import matplotlib
import matplotlib.colors
import PIL.Image

EXTENSION = ".png"

Expand Down Expand Up @@ -35,7 +36,13 @@ def run(
alpha=parameters["alpha"],
background_colour=matplotlib.colors.to_rgba(parameters["background_color"]),
)
image.save(
image.resize(
size=(
image.width * parameters["scale"],
image.height * parameters["scale"],
),
resample=PIL.Image.Resampling.NEAREST, # type: ignore
).save(
str(output),
compress_level=parameters["png_compression_level"],
format="png",
Expand Down
6 changes: 5 additions & 1 deletion charidotella/tasks/event_rate.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@ def run(
):
subprocess.run(
[
str(importlib.resources.files("charidotella").joinpath("executables/event_rate")),
str(
importlib.resources.files("charidotella").joinpath(
"executables/event_rate"
)
),
str(input),
str(output),
f"--begin={begin}",
Expand Down
15 changes: 13 additions & 2 deletions charidotella/tasks/video.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,30 @@ def run(
int(value)
for value in subprocess.run(
[
str(importlib.resources.files("charidotella").joinpath("executables/size")),
str(
importlib.resources.files("charidotella").joinpath(
"executables/size"
)
),
str(input),
],
check=True,
capture_output=True,
).stdout.split(b"x")
)
width *= parameters["scale"]
height *= parameters["scale"]
es_to_frames_arguments = [
str(importlib.resources.files("charidotella").joinpath("executables/es_to_frames")),
str(
importlib.resources.files("charidotella").joinpath(
"executables/es_to_frames"
)
),
f"--input={input}",
f"--begin={begin}",
f"--end={end}",
f"--frametime={parameters['frametime']}",
f"--scale={parameters['scale']}",
f"--style={parameters['style']}",
f"--tau={parameters['tau']}",
f"--oncolor={parameters['on_color']}",
Expand Down
1 change: 1 addition & 0 deletions charidotella/tasks/wiggle.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ def run(
f"--begin={begin}",
f"--end={end}",
f"--frametime={frametime}",
f"--scale={parameters['scale']}",
f"--style={parameters['style']}",
f"--tau={tau}",
f"--oncolor={parameters['on_color']}",
Expand Down
2 changes: 1 addition & 1 deletion command_line_tools
19 changes: 17 additions & 2 deletions configuration-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,10 @@
"background_color": {
"type": "string"
},
"scale": {
"type": "integer",
"exclusiveMinimum": 0
},
"cycle": {
"type": ["string", "integer"]
}
Expand All @@ -136,7 +140,8 @@
"colormap",
"alpha",
"png_compression_level",
"background_color"
"background_color",
"scale"
]
},
{
Expand Down Expand Up @@ -245,6 +250,10 @@
"ffmpeg": {
"type": "string"
},
"scale": {
"type": "integer",
"exclusiveMinimum": 0
},
"lambda_max": {
"type": "number",
"minimum": 0.0
Expand All @@ -263,6 +272,7 @@
"cumulative_ratio",
"timecode",
"h264_crf",
"scale",
"ffmpeg"
]
},
Expand Down Expand Up @@ -313,6 +323,10 @@
"ffmpeg": {
"type": "string"
},
"scale": {
"type": "integer",
"exclusiveMinimum": 0
},
"lambda_max": {
"type": "number",
"minimum": 0.0
Expand All @@ -329,7 +343,8 @@
"off_color",
"idle_color",
"cumulative_ratio",
"ffmpeg"
"ffmpeg",
"scale"
]
}
]
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@

setuptools.setup(
name="charidotella",
version="0.2",
version="0.3",
url="https://github.com/neuromorphicsystems/charidotella",
author="Alexandre Marcireau",
author_email="alexandre.marcireau@gmail.com",
Expand Down

0 comments on commit ed68b32

Please sign in to comment.