HH_/horizontal.simple.py
2015-10-15 18:16:50 +02:00

70 lines
1.6 KiB
Python

#!/usr/bin/python
import os, sys, Image, ImageDraw, ImageColor
from time import gmtime, strftime
fichier=sys.argv[1]
try:
#Image.open(fichier).save(outfile)
im1 = Image.open(fichier).convert('1')
im2 = im1.copy()
im3 = im1.copy()
draw = ImageDraw.Draw(im2)
except IOError:
print "FICHIER!!!", infile
date = strftime("%Y%m%d-%Hh%Mm%Ss", gmtime())
x=0
while x < im1.size[0] :
y = 0
while y < im1.size[1] :
colorpixel = im1.getpixel((x,y))
draw.line( (0, y, im2.size[0], y) , fill=colorpixel)
draw.line((x, 0, x, im2.size[1]-1), fill=1)
y = y + 1
#draw = ImageDraw.Draw(im2)
#lignes noires 1px autour
#draw.line((0, 0, im3.size[0]-1, 0), fill="rgb(255,255,255)")
#draw.line((x, 0, x, im2.size[1]-1), fill="rgb(255,0,0)")
#------------------------------------------
# ALPHA tout bete :
im3 = Image.blend(im1, im2, 0.8)
# COMPOSITING :
# im3 = Image.composite(im1, im2, mask)
#im3 = Image.composite(im1, im2, im1)
#------------------------------------------
n = "%05d" % x
nomdefichier = "horizontal"+n+".png"
im3.save(nomdefichier, "PNG")
print nomdefichier
x = x + 1
#im4.save(script+"."+strftime('%Y%m%d-%Hh%Mm%Ss', gmtime())+".jpg",'JPEG', quality=100)
del draw
#os.system("ffmpeg -i horizontal%d.png -vcodec mjpeg -q:v 0 "+fichier+".avi")
os.system("ffmpeg -i horizontal%05d.png -i "+fichier+".enscribe.norm.wav -c:a libfaac -c:v libx264 -preset ultrafast -crf 32 "+fichier+".final.mp4")
print " OUTPUT FINAL : "+fichier+".final.mp4"
#os.system("rm horizontal*.png")
# ALPHA :
# out = image1 * (1.0 - alpha) + image2 * alpha