Skip to main content

Generate a petting gif from a static image (known as "petpet", "Pet the X", or "PETTHE").

Project description

pet-pet-gif

Python adaptation of https://github.com/aDu/pet-pet-gif

Usage:

I had some Issues with Pet-pet with pkg_resources on termux It didnt fix itself so im using the modern method now. technically old cause i wanted it to be backwards compatible

from petpetgif import petpet  
petpet.make(source, dest)
  • source: A filename (string), pathlib.Path object or a file object. (This parameter corresponds and is passed to the PIL.Image.open() method.)

  • dest: A filename (string), pathlib.Path object or a file object. (This parameter corresponds and is passed to the PIL.Image.save() method.)

Basic example:

from petpetgif import petpet
petpet.make('test.png', 'out.gif')

Discord.py example:

import os
import discord
from discord.ext import commands
from dotenv import load_dotenv
from io import BytesIO
from typing import Union, Optional
from petpetgif import petpet as petpetgif

load_dotenv()
token = os.getenv('DISCORD_BOT_TOKEN')

client = commands.Bot(command_prefix='!')

@client.event
async def on_ready():
    print('Bot is ready.')

@client.command()
async def pet(ctx, image: Optional[Union[discord.PartialEmoji, discord.member.Member]]):
    if type(image) == discord.PartialEmoji:
        image = await image.url_as(format='png').read() # retrieve the image bytes
    elif type(image) == discord.member.Member:
        image = await image.avatar_url_as(format='png').read() # retrieve the image bytes
    else:
        await ctx.reply('Please use a custom emoji or tag a member to petpet their avatar.')
        return

    source = BytesIO(image) # file-like container to hold the emoji in memory
    dest = BytesIO() # container to store the petpet gif in memory
    petpetgif.make(source, dest)
    dest.seek(0) # set the file pointer back to the beginning so it doesn't upload a blank file.
    await ctx.send(file=discord.File(dest, filename=f"{image[0]}-petpet.gif"))


client.run(token)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pet_pet_gif_fix-1.0.3.tar.gz (20.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pet_pet_gif_fix-1.0.3-py3-none-any.whl (36.4 kB view details)

Uploaded Python 3

File details

Details for the file pet_pet_gif_fix-1.0.3.tar.gz.

File metadata

  • Download URL: pet_pet_gif_fix-1.0.3.tar.gz
  • Upload date:
  • Size: 20.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.14

File hashes

Hashes for pet_pet_gif_fix-1.0.3.tar.gz
Algorithm Hash digest
SHA256 d1573f8ad335fd1bd64fc1e1295399ac10710d957022c5c4d07cfa4eabb9d60a
MD5 9011becb280509bf299af0e81c800c31
BLAKE2b-256 2c8f2026a2a618a6fd9b198e52bc7cfd973e984e5e2ee7ee7e1979c3cb7066ef

See more details on using hashes here.

File details

Details for the file pet_pet_gif_fix-1.0.3-py3-none-any.whl.

File metadata

File hashes

Hashes for pet_pet_gif_fix-1.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 d1cfbb594ecd505ae7498413ca774322347855a0a31533de769892dbeec8f07e
MD5 0799d18038f4fb0029173119b7f8d81a
BLAKE2b-256 cd28576eca0694c3c9929ee49af272e1b31dfb459d8918ea9edb8938472476b9

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page