Skip to content

Commit

Permalink
feat: add meme out (#97)
Browse files Browse the repository at this point in the history
* feat: add meme `out`

* fix: remove useless code

* fix: adjust position

* style: auto fix by pre-commit hooks

* fix: rename function

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
ikechan8370 and pre-commit-ci[bot] committed Apr 26, 2024
1 parent 1b4364e commit d03ce28
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 0 deletions.
Binary file added docs/images/out.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
30 changes: 30 additions & 0 deletions meme_generator/memes/out/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
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 out(images: List[BuildImage], texts, args):
frame = BuildImage.open(img_dir / "out.png")

def make(img: BuildImage) -> BuildImage:
img = img.convert("RGBA")
out = frame.copy().resize_width(int(img.width * 0.5), keep_ratio=True)
return img.paste(
out,
(
min(img.width - out.width - 10, int(img.width * 0.4)),
min(img.height - out.height - 10, int(img.height * 0.7)),
),
alpha=True,
)

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


add_meme("out", out, min_images=1, max_images=1, keywords=["out"])
Binary file added meme_generator/memes/out/images/out.png
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 d03ce28

Please sign in to comment.