Skip to content

Commit

Permalink
new meme raise_image (#50)
Browse files Browse the repository at this point in the history
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
lgc2333 and pre-commit-ci[bot] committed Aug 9, 2023
1 parent 06f7917 commit c4b3f74
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions meme_generator/memes/raise_image/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
from io import BytesIO
from pathlib import Path
from typing import List

from pil_utils import BuildImage

from meme_generator import add_meme
from meme_generator.utils import make_jpg_or_gif

img_dir = Path(__file__).parent / "images"


def raise_image(images: List[BuildImage], texts, args) -> BytesIO: # noqa: ARG001
inner_size = (599, 386)
paste_pos = (134, 91)

bg = BuildImage.open(img_dir / "raise_image.png")

def make_frame(img: BuildImage) -> BuildImage:
inner_frame = BuildImage.new("RGBA", inner_size, "white")
inner_frame = inner_frame.paste(
img.convert("RGBA").resize(inner_size, keep_ratio=True),
alpha=True,
)
return bg.copy().paste(inner_frame, paste_pos, alpha=True, below=True)

return make_jpg_or_gif(images[0], make_frame, keep_transparency=True)


add_meme(
"raise_image",
raise_image,
min_images=1,
max_images=1,
keywords=["举"],
)
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit c4b3f74

Please sign in to comment.