Skip to content

Instantly share code, notes, and snippets.

View MikeTheWatchGuy's full-sized avatar
🎯
Focusing

MikeTheWatchGuy

🎯
Focusing
View GitHub Profile
@alexflint
alexflint / make_video.py
Last active November 10, 2021 16:36
Create a video from a sequence of images (or PDFs) in python (using ffmpeg internally)
import os
import sys
import tempfile
import argparse
import subprocess
NATURAL_FPS = 30.
# Formats convertible by imagemagick:
CONVERTIBLE_EXTENSIONS = ['png', 'jpeg', 'jpg', 'pdf', 'pgm', 'bmp']
@cdiener
cdiener / asciinator.py
Last active January 5, 2023 17:24
Convert image to ascii art
import sys; from PIL import Image; import numpy as np
chars = np.asarray(list(' .,:;irsXA253hMHGS#9B&@'))
if len(sys.argv) != 4: print( 'Usage: ./asciinator.py image scale factor' ); sys.exit()
f, SC, GCF, WCF = sys.argv[1], float(sys.argv[2]), float(sys.argv[3]), 7/4
img = Image.open(f)
S = ( round(img.size[0]*SC*WCF), round(img.size[1]*SC) )
img = np.sum( np.asarray( img.resize(S) ), axis=2)