Skip to content

Instantly share code, notes, and snippets.

@yohhoy
Created April 16, 2016 08:32
Show Gist options
  • Save yohhoy/4551cf51c5335c3addc81bdbc1d1e73b to your computer and use it in GitHub Desktop.
Save yohhoy/4551cf51c5335c3addc81bdbc1d1e73b to your computer and use it in GitHub Desktop.
"Pixel art saved with JPEG format" image filter
#!/usr/bin/env python3
import cv2
import numpy as np
import sys
def convert(infile, outfile):
src = cv2.imread(infile)
params = [int(cv2.IMWRITE_JPEG_QUALITY), 10]
_, jpeg = cv2.imencode('.jpg', src, params)
img = cv2.imdecode(jpeg, 1)
cv2.imwrite(outfile, img)
if __name__ == '__main__':
if len(sys.argv) < 3:
print("usage: {} <infile> <outfile>\n".format(__file__))
sys.exit(0)
convert(sys.argv[1], sys.argv[2])
@yohhoy
Copy link
Author

yohhoy commented Apr 16, 2016

Special thanks to https://twitter.com/jpeghozondotbot (ja)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment