Last active
December 1, 2023 05:49
-
-
Save Sebastian1011/c96a519b83ece4aa7f7a868a2026d682 to your computer and use it in GitHub Desktop.
format image python script( use python and ffmpeg
This file contains 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/python | |
#coding=utf-8 | |
import os | |
import sys | |
import re | |
def readFile(filePath): | |
allFiles = os.listdir(filePath) | |
fileList = [] | |
for fileName in allFiles: | |
if re.search(r'[.](jpg|gif|bmg)$', fileName): | |
fullPath = filePath + fileName | |
fileList.append(fullPath) | |
return fileList | |
def transform(list): | |
for imageIn in list: | |
imageOut = re.sub(r'[.](jpg|gif|bmg)$', '.png' , imageIn) | |
cmd = 'ffmpeg -y -i '+ imageIn + ' ' +imageOut | |
os.system(cmd) | |
print imageOut | |
def main(): | |
print 'this is main' | |
argNum = len(sys.argv) | |
if argNum <= 1: | |
print 'please input path and format' | |
return | |
filePath = sys.argv[1] | |
fileList = readFile(filePath) | |
transform(fileList) | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
make public