Created
April 16, 2016 08:32
-
-
Save yohhoy/4551cf51c5335c3addc81bdbc1d1e73b to your computer and use it in GitHub Desktop.
"Pixel art saved with JPEG format" image filter
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Special thanks to https://twitter.com/jpeghozondotbot (ja)