Skip to content

Commit 7d0bef6

Browse files
committed
Rearranged Defs
1 parent 9970b8d commit 7d0bef6

File tree

3 files changed

+26
-28
lines changed

3 files changed

+26
-28
lines changed

mediaify/animation/exports.py

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,33 +9,31 @@ def load_animation(data: bytes) -> "AnimationFile":
99
"""Raises:
1010
- ValueError("Animation was too large")
1111
- ValueError("Could not Load Animation")
12-
- ValueError("Animation Only Has 1 Frame")
1312
"""
1413
pillow = open_as_pillow(data)
1514
return encode_as_original(data, pillow)
1615

1716

18-
def batch_encode_animation(
17+
def encode_animation(
1918
data: bytes,
20-
configs: "List[AnimationConfig]" = Default.batch_animation,
21-
) -> "List[AnimationFile|ImageFile]":
19+
config: AnimationConfig = Default.animation,
20+
) -> "AnimationFile|ImageFile":
2221
"""Raises:
2322
- ValueError("Animation was too large")
2423
- ValueError("Could not Load Animation")
25-
- ValueError("Animation Only Has 1 Frame")
2624
"""
2725
pillow = open_as_pillow(data)
28-
return [encode_with_config(data, pillow, config) for config in configs]
26+
return encode_with_config(data, pillow, config)
2927

3028

31-
def encode_animation(
29+
def batch_encode_animation(
3230
data: bytes,
33-
config: AnimationConfig = Default.animation,
34-
) -> "AnimationFile|ImageFile":
31+
configs: "List[AnimationConfig]" = Default.batch_animation,
32+
) -> "List[AnimationFile|ImageFile]":
3533
"""Raises:
3634
- ValueError("Animation was too large")
3735
- ValueError("Could not Load Animation")
3836
"""
3937
pillow = open_as_pillow(data)
40-
return encode_with_config(data, pillow, config)
38+
return [encode_with_config(data, pillow, config) for config in configs]
4139

mediaify/image/exports.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,25 +14,25 @@ def load_image(data: bytes) -> "ImageFile":
1414
return encode_with_config(data, pillow, UnencodedConfig())
1515

1616

17-
def batch_encode_image(
17+
def encode_image(
1818
data: bytes,
19-
configs: "List[ImageConfig]" = Default.batch_image,
20-
) -> "List[ImageFile]":
19+
config: ImageConfig = Default.image,
20+
) -> "ImageFile":
2121
"""Raises:
2222
- ValueError: Image is too big to process
2323
- ValueError: Could not Load Image
2424
"""
2525
pillow = open_as_pillow(data)
26-
return [encode_with_config(data, pillow, config) for config in configs]
26+
return encode_with_config(data, pillow, config)
2727

2828

29-
def encode_image(
29+
def batch_encode_image(
3030
data: bytes,
31-
config: ImageConfig = Default.image,
32-
) -> "ImageFile":
31+
configs: "List[ImageConfig]" = Default.batch_image,
32+
) -> "List[ImageFile]":
3333
"""Raises:
3434
- ValueError: Image is too big to process
3535
- ValueError: Could not Load Image
3636
"""
3737
pillow = open_as_pillow(data)
38-
return encode_with_config(data, pillow, config)
38+
return [encode_with_config(data, pillow, config) for config in configs]

mediaify/video/exports.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,16 @@ def load_video(data: bytes) -> "VideoFile":
1515
return encode_as_original(data, info)
1616

1717

18+
def encode_video(
19+
data: bytes,
20+
config: "VideoConfig" = Default.video,
21+
) -> "VideoFile|AnimationFile|ImageFile":
22+
with NamedTemporaryFile() as f:
23+
f.write(data)
24+
info = get_video_info(f.name)
25+
return encode_video_with_config(data, f.name, info, config)
26+
27+
1828
def batch_encode_video(
1929
data: bytes,
2030
configs: "List[VideoConfig]" = Default.batch_video,
@@ -26,13 +36,3 @@ def batch_encode_video(
2636
encode_video_with_config(data, f.name, info, config)
2737
for config in configs
2838
]
29-
30-
31-
def encode_video(
32-
data: bytes,
33-
config: "VideoConfig" = Default.video,
34-
) -> "VideoFile|AnimationFile|ImageFile":
35-
with NamedTemporaryFile() as f:
36-
f.write(data)
37-
info = get_video_info(f.name)
38-
return encode_video_with_config(data, f.name, info, config)

0 commit comments

Comments
 (0)