Added code to produce a high resolution file for customer delivery
This commit is contained in:
4
.gitignore
vendored
4
.gitignore
vendored
@@ -1,9 +1,11 @@
|
||||
full-res-files/*
|
||||
web-files/*
|
||||
high-res/*
|
||||
!full-res-files/DELETE-ME.txt
|
||||
!web-files/DELETE-ME.txt
|
||||
!high-res/DELETE-ME.txt
|
||||
imagemagick/*
|
||||
!imagemagick/PLACEHOLDER.txt
|
||||
profile.icc
|
||||
imagemagick.zip
|
||||
imagemagick.tar.gz
|
||||
imagemagick.tar.gz
|
||||
|
||||
39
convert.py
39
convert.py
@@ -6,6 +6,7 @@ import tarfile
|
||||
|
||||
inputFolder = 'full-res-files'
|
||||
outputFolder = 'web-files'
|
||||
highResOutput = 'high-res'
|
||||
magickHome = ""
|
||||
dyldLibrary = ""
|
||||
|
||||
@@ -20,17 +21,27 @@ def convertFilesInInput():
|
||||
os.rename(os.path.join(inputFolder,filename), os.path.join(inputFolder,filename.replace(' ', '-')))
|
||||
|
||||
for filename in os.listdir(inputFolder):
|
||||
print("Converting " + filename)
|
||||
#os.path.splitext(filename)[0] gets rid of file extension if you want a different extension
|
||||
getProfileCmd = getImagemagickExe() + " " + getInputPath() + filename + " profile.icc"
|
||||
convertCmd = getImagemagickExe() + " " + getInputPath() + filename + " -resize \"1500x\" -quality 60 -depth 24 -strip -profile \"profile.icc\" " + getOutputPath() + filename
|
||||
if(os.name == "nt"):
|
||||
os.system(getProfileCmd)
|
||||
os.system(convertCmd)
|
||||
else:
|
||||
os.system(magickHome + dyldLibrary + getProfileCmd)
|
||||
os.system(magickHome + dyldLibrary + convertCmd)
|
||||
os.remove("profile.icc")
|
||||
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
|
||||
getProfileCmd = getImagemagickExe() + " " + getInputPath() + filename + " profile.icc"
|
||||
# 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"):
|
||||
os.system(getProfileCmd)
|
||||
os.system(convertCmd)
|
||||
else:
|
||||
os.system(magickHome + dyldLibrary + getProfileCmd)
|
||||
os.system(magickHome + dyldLibrary + convertCmd)
|
||||
os.remove("profile.icc")
|
||||
|
||||
|
||||
def downloadImagemagick():
|
||||
if not os.path.isfile(getImagemagickExe()):
|
||||
@@ -75,6 +86,12 @@ def getOutputPath():
|
||||
else:
|
||||
return outputFolder + "/"
|
||||
|
||||
def getOutputPathHighRes():
|
||||
if(os.name == "nt"):
|
||||
return highResOutput + "\\"
|
||||
else:
|
||||
return highResOutput + "/"
|
||||
|
||||
def getInputPath():
|
||||
if(os.name == "nt"):
|
||||
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