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.4.tar.gz (20.7 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.4-py3-none-any.whl (36.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pet_pet_gif_fix-1.0.4.tar.gz
  • Upload date:
  • Size: 20.7 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.4.tar.gz
Algorithm Hash digest
SHA256 83da6b2f4e7c26b564a4c171f476bac151a9b5bc1ce782bcec037f49cf216072
MD5 3b644ff1b5b752a5d8d21d9e8394f112
BLAKE2b-256 36a034ca0528dc3c985adc5d39e924d9979582aa539e76468e8d67b17d992878

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pet_pet_gif_fix-1.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 03d601e525c6a93616af57aa5832a996a8f23b9b6898c649e058e59b1602d5f7
MD5 1e4ba199c2b4f8ce75770fabc319f9e1
BLAKE2b-256 17cbcd7bb6c41dfc81a528e8746760cbc6460d416fa7367ed2840249e1275049

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