Skip to content

Commit

Permalink
feat: add meme stew and tom_tease (#85)
Browse files Browse the repository at this point in the history
* 炖 和 汤姆嘲笑

* style: auto fix by pre-commit hooks

* adjust stew

* adjust watch_tv

* rename watch_tv to tom_tease

* remove extra files

* adjust stew

---------

Co-authored-by: leinlin <[email protected]>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: meetwq <[email protected]>
  • Loading branch information
4 people committed Jan 19, 2024
1 parent ad9cb6d commit ddb42fc
Show file tree
Hide file tree
Showing 14 changed files with 79 additions and 0 deletions.
44 changes: 44 additions & 0 deletions meme_generator/memes/stew/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
from pathlib import Path
from typing import List

from pil_utils import BuildImage

from meme_generator import MemeArgsModel, add_meme
from meme_generator.exception import TextOverLength
from meme_generator.utils import make_jpg_or_gif

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


def stew(images: List[BuildImage], texts: List[str], args: MemeArgsModel):
name = texts[0] if texts else args.user_infos[0].name if args.user_infos else "群友"
text = f"生活不易,炖{name}出气"

frame = BuildImage.open(img_dir / "0.png")
try:
frame.draw_text(
(2, frame.height - 30, frame.width - 2, frame.height),
text,
max_fontsize=30,
min_fontsize=6,
lines_align="center",
)
except ValueError:
raise TextOverLength(name)

def make(img: BuildImage) -> BuildImage:
img = img.convert("RGBA").resize((181, 154), keep_ratio=True)
return frame.copy().paste(img, (9, -2), below=True)

return make_jpg_or_gif(images[0], make)


add_meme(
"stew",
stew,
min_images=1,
max_images=1,
min_texts=0,
max_texts=1,
keywords=["炖"],
)
Binary file added meme_generator/memes/stew/images/0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
35 changes: 35 additions & 0 deletions meme_generator/memes/tom_tease/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
from pathlib import Path
from typing import List

from pil_utils import BuildImage

from meme_generator import add_meme
from meme_generator.utils import FrameAlignPolicy, Maker, make_gif_or_combined_gif

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


def tom_tease(images: List[BuildImage], texts, args):
def maker(i: int) -> Maker:
def make(img: BuildImage) -> BuildImage:
img = img.convert("RGBA").resize((400, 350), keep_ratio=True)
img = img.perspective(((0, 100), (290, 0), (290, 370), (0, 335)))
bg = BuildImage.open(img_dir / f"{i}.png")
frame = BuildImage.new("RGBA", bg.size, "white")
frame.paste(bg).paste(img, (258, -12), below=True)
return frame

return make

return make_gif_or_combined_gif(
images[0], maker, 11, 0.2, FrameAlignPolicy.extend_first
)


add_meme(
"tom_tease",
tom_tease,
min_images=1,
max_images=1,
keywords=["汤姆嘲笑"],
)
Binary file added meme_generator/memes/tom_tease/images/0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added meme_generator/memes/tom_tease/images/1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added meme_generator/memes/tom_tease/images/10.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added meme_generator/memes/tom_tease/images/2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added meme_generator/memes/tom_tease/images/3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added meme_generator/memes/tom_tease/images/4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added meme_generator/memes/tom_tease/images/5.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added meme_generator/memes/tom_tease/images/6.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added meme_generator/memes/tom_tease/images/7.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added meme_generator/memes/tom_tease/images/8.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added meme_generator/memes/tom_tease/images/9.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 ddb42fc

Please sign in to comment.