Skip to content

Instantly share code, notes, and snippets.

@ice2heart
Created September 25, 2018 08:38
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 ice2heart/50afc0da02d8b061f725f17d36d5be6f to your computer and use it in GitHub Desktop.
Save ice2heart/50afc0da02d8b061f725f17d36d5be6f to your computer and use it in GitHub Desktop.
JPEG degradation
#!/usr/bin/env python3
# setup
# sudo apt install libmagickwand-dev ffmpeg
# pip3 install Wand progressbar
# ffmpeg -framerate 30 -i out/%05d.jpg -c:v libx264 -r 30 jpeg.mp4
from random import randrange
from wand.image import Image
import progressbar
last_name = 'src0.jpg'
for i in progressbar.progressbar(range(300)):
with Image(filename=last_name) as img:
last_name = 'out/%05d.jpg' % i
with img.clone() as im:
im.compression = 'jpeg'
im.compression_quality = randrange(10, 70)
im.save(filename=last_name)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment