Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 64 additions & 0 deletions scripts/photofilmstrip-auto
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
#!/usr/bin/python
# -*- coding: utf-8
"""
Contributed by Yoandy S <yoandy.shyno@gmail.com>
"""
import argparse
import sys
import os
import glob
from photofilmstrip.CLI import main as photofilmstrip_cli
from photofilmstrip.core.Project import Project
from photofilmstrip.core.ProjectFile import ProjectFile
from photofilmstrip.core.Picture import Picture
from photofilmstrip.action.ActionAutoPath import ActionAutoPath


def make_project(path, project_path, duration, time_per_image):
project = Project()
images = []
for picpath in glob.glob(path + '*.jpg') + glob.glob(path + '*.JPG'):
picture = Picture(picpath)
actAp = ActionAutoPath(picture, project.GetAspect())
actAp.Execute()
images.append(picture)
if not duration:
duration = len(images) * time_per_image
project.SetDuration(duration)
project.SetPictures(images)
project_file = ProjectFile(project, project_path)
project_file.Save()


if __name__ == '__main__':
parser = argparse.ArgumentParser(description='Generate video from images in\
a directory.')
parser.add_argument("directory_path", help="Path of directory with source\
images.")
parser.add_argument("-d", "--destination-path",
help="Path where output files will be created.")
parser.add_argument("-u", "--duration", default=0, type=int,
help="Set the duration of the output Video.")
parser.add_argument("-x", "--time-per-image", default=10, type=int,
help="This is use to calculate the total time based on\
the number of images.")
args = parser.parse_args()
if args.time_per_image and args.duration:
print("WARNING: The time-per-image Value is ignored.")
if not args.destination_path:
WD = os.path.join(args.directory_path, "output")
try:
if not os.path.exists(WD):
os.mkdir(WD)
except PermissionError:
print("Permission denied: error creating directory.")
path = os.path.normpath(args.directory_path) + '/'
project_name = 'photofilmstrip-prj-' + str(os.stat(path).st_ino) + '.pfs'
project_path = os.path.join(WD, project_name)
if os.path.exists(project_path):
print ("WARNING: Project file already exist, will be overwritten")

make_project(path, project_path, args.duration, args.time_per_image)
sys.argv = [sys.argv[0]] +\
'-p {} -o {} -t 2 -f 5'.format(project_path, WD).split()
photofilmstrip_cli()
4 changes: 4 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -581,6 +581,9 @@ def Unzip(zipFile, targetDir, stripFolders=0):
platform_scripts = []
platform_data = []
if os.name == "nt":
platform_scripts.append(os.path.join("windows", "photofilmstrip-auto.bat"))
platform_data.append(os.path.join("share", "doc", "photofilmstrip"))
platform_scripts.append(os.path.join("windows", "photofilmstrip.chm"))
platform_scripts.append(os.path.join("windows", "photofilmstrip.bat"))
platform_scripts.append(os.path.join("windows", "photofilmstrip-cli.bat"))
else:
Expand Down Expand Up @@ -686,6 +689,7 @@ def Unzip(zipFile, targetDir, stripFolders=0):
scripts=[
"scripts/photofilmstrip",
"scripts/photofilmstrip-cli",
"scripts/photofilmstrip-auto"
] + platform_scripts,

name=Constants.APP_NAME.lower(),
Expand Down
2 changes: 2 additions & 0 deletions windows/photofilmstrip-auto.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
@"%~dp0..\python" "%~dp0photofilmstrip-auto" %*