Skip to content

Instantly share code, notes, and snippets.

@chriswmartin
Created May 15, 2017 23:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chriswmartin/d867720507aafbfb146cd26c2a0f48bf to your computer and use it in GitHub Desktop.
Save chriswmartin/d867720507aafbfb146cd26c2a0f48bf to your computer and use it in GitHub Desktop.
from PIL import Image
import numpy as np
import os, random
from mastodon import Mastodon
folder=r"/home/cwm/glitchgarden/images/"
a=random.choice(os.listdir(folder))
print(a)
im1 = Image.open(folder+a)
im2 = Image.open(folder+a)
im3 = Image.open(folder+a)
for y in range(0, np.random.randint(50,200)):
vals = np.random.randint(0, 500, size=16)
crop1 = im1.crop((vals[0],vals[1],vals[2],vals[3]))
crop2 = im2.crop((vals[4],vals[5],vals[6],vals[7]))
crop3 = im3.crop((vals[8],vals[9],vals[10],vals[11]))
im1.paste(crop1,(vals[12],vals[13]))
im1.paste(crop2,(vals[14],vals[15]))
im1.paste(crop3,(vals[14],vals[15]))
im1.save("flower.png")
mastodon_client = Mastodon(
client_id = 'pytooter_clientcred.txt',
api_base_url="https://botsin.space"
)
r = mastodon_client.log_in(
"[email]",
"[password]",
to_file = 'pytooter_usercred.txt'
)
file_to_upload = 'flower.png'
media_dict = mastodon_client.media_post(file_to_upload)
emojis = [':cherry_blossom:', ':rosette:', ':rose:', ':wilted_rose:', ':hibiscus:', ':blossom:', ':maple_leaf:', ':cactus:', ':palm_tree:', ':sunflower:', ':blossom:', ':tulip:', ':seedling:', ':evergreen_tree:', ':deciduous_tree:']
status_text=random.choice(emojis)
mastodon_client.status_post(status=status_text, in_reply_to_id=None, media_ids=[media_dict])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment