Skip to content

Instantly share code, notes, and snippets.

@Sebastian1011
Last active December 1, 2023 05:49
Show Gist options
  • Save Sebastian1011/c96a519b83ece4aa7f7a868a2026d682 to your computer and use it in GitHub Desktop.
Save Sebastian1011/c96a519b83ece4aa7f7a868a2026d682 to your computer and use it in GitHub Desktop.
format image python script( use python and ffmpeg
#!/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()
@Sebastian1011
Copy link
Author

make public

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