Added code to produce a high resolution file for customer delivery
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -1,7 +1,9 @@
|
|||||||
full-res-files/*
|
full-res-files/*
|
||||||
web-files/*
|
web-files/*
|
||||||
|
high-res/*
|
||||||
!full-res-files/DELETE-ME.txt
|
!full-res-files/DELETE-ME.txt
|
||||||
!web-files/DELETE-ME.txt
|
!web-files/DELETE-ME.txt
|
||||||
|
!high-res/DELETE-ME.txt
|
||||||
imagemagick/*
|
imagemagick/*
|
||||||
!imagemagick/PLACEHOLDER.txt
|
!imagemagick/PLACEHOLDER.txt
|
||||||
profile.icc
|
profile.icc
|
||||||
|
|||||||
21
convert.py
21
convert.py
@@ -6,6 +6,7 @@ import tarfile
|
|||||||
|
|
||||||
inputFolder = 'full-res-files'
|
inputFolder = 'full-res-files'
|
||||||
outputFolder = 'web-files'
|
outputFolder = 'web-files'
|
||||||
|
highResOutput = 'high-res'
|
||||||
magickHome = ""
|
magickHome = ""
|
||||||
dyldLibrary = ""
|
dyldLibrary = ""
|
||||||
|
|
||||||
@@ -20,10 +21,19 @@ def convertFilesInInput():
|
|||||||
os.rename(os.path.join(inputFolder,filename), os.path.join(inputFolder,filename.replace(' ', '-')))
|
os.rename(os.path.join(inputFolder,filename), os.path.join(inputFolder,filename.replace(' ', '-')))
|
||||||
|
|
||||||
for filename in os.listdir(inputFolder):
|
for filename in os.listdir(inputFolder):
|
||||||
print("Converting " + filename)
|
print("Converting " + filename + " for web.")
|
||||||
|
convertImage("1500","50",filename,getOutputPath())
|
||||||
|
|
||||||
|
for filename in os.listdir(inputFolder):
|
||||||
|
print("Converting " + filename + " for delivery.")
|
||||||
|
# 6000x can give you a 20 inch image for print. Printing is 300dpi so 6000px/300dpi = 20inch, but if someone wants a 20x16 your smaller edge needs to be 4800px
|
||||||
|
convertImage("8000","50",filename,getOutputPathHighRes())
|
||||||
|
|
||||||
|
def convertImage(pixels,quality,filename,outputPath):
|
||||||
#os.path.splitext(filename)[0] gets rid of file extension if you want a different extension
|
#os.path.splitext(filename)[0] gets rid of file extension if you want a different extension
|
||||||
getProfileCmd = getImagemagickExe() + " " + getInputPath() + filename + " profile.icc"
|
getProfileCmd = getImagemagickExe() + " " + getInputPath() + filename + " profile.icc"
|
||||||
convertCmd = getImagemagickExe() + " " + getInputPath() + filename + " -resize \"1500x\" -quality 60 -depth 24 -strip -profile \"profile.icc\" " + getOutputPath() + filename
|
# pixels and profile need double quotes around them
|
||||||
|
convertCmd = getImagemagickExe() + " " + getInputPath() + filename + " -resize \"" + pixels + "x\" -quality " + quality + " -depth 24 -strip -profile \"profile.icc\" " + outputPath + filename
|
||||||
if(os.name == "nt"):
|
if(os.name == "nt"):
|
||||||
os.system(getProfileCmd)
|
os.system(getProfileCmd)
|
||||||
os.system(convertCmd)
|
os.system(convertCmd)
|
||||||
@@ -32,6 +42,7 @@ def convertFilesInInput():
|
|||||||
os.system(magickHome + dyldLibrary + convertCmd)
|
os.system(magickHome + dyldLibrary + convertCmd)
|
||||||
os.remove("profile.icc")
|
os.remove("profile.icc")
|
||||||
|
|
||||||
|
|
||||||
def downloadImagemagick():
|
def downloadImagemagick():
|
||||||
if not os.path.isfile(getImagemagickExe()):
|
if not os.path.isfile(getImagemagickExe()):
|
||||||
print("ImageMagick does not exist. Downloading now...")
|
print("ImageMagick does not exist. Downloading now...")
|
||||||
@@ -75,6 +86,12 @@ def getOutputPath():
|
|||||||
else:
|
else:
|
||||||
return outputFolder + "/"
|
return outputFolder + "/"
|
||||||
|
|
||||||
|
def getOutputPathHighRes():
|
||||||
|
if(os.name == "nt"):
|
||||||
|
return highResOutput + "\\"
|
||||||
|
else:
|
||||||
|
return highResOutput + "/"
|
||||||
|
|
||||||
def getInputPath():
|
def getInputPath():
|
||||||
if(os.name == "nt"):
|
if(os.name == "nt"):
|
||||||
return inputFolder + "\\"
|
return inputFolder + "\\"
|
||||||
|
|||||||
0
high-res/DELETE-ME.txt
Normal file
0
high-res/DELETE-ME.txt
Normal file
Reference in New Issue
Block a user