-
Notifications
You must be signed in to change notification settings - Fork 0
/
VIPS_exe.py
40 lines (29 loc) · 983 Bytes
/
VIPS_exe.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File conversion utilities library
import os, shutil
'''
Tiny wrapper around the VIPS executable.
To use it simply:
import VIPS_exe
VIPS_dzsave('path-to-input-file','path-to-output-dirName')
Author: Thomas Pengo
License: GPL 3
'''
VIPS_EXECUTABLE="C:\\vips-dev-7.42.0\\bin\\vips.exe "
TEMPLATE_FILE=os.path.join(os.path.dirname(__file__),"template.html")
def VIPS_setPath(newPath):
VIPS_EXECUTABLE=newPath
def VIPS_call(command, inputFile, outputFile, parameters):
import subprocess
subprocess.call(" ".join((VIPS_EXECUTABLE,command,'"'+inputFile+'"','"'+outputFile+'"',parameters)))
def VIPS_dzsave(inputFile, outputFile, layout="google", progress=True, suffix=".png[compression=9]"):
if layout=='google':
outputFile=outputFile
templateFile=outputFile+".html"
VIPS_call("dzsave",
inputFile,
outputFile,
" ".join((
"--layout",layout,
"--vips-progress" if progress else "")))
if layout=='google':
shutil.copyfile(TEMPLATE_FILE,templateFile)