Added code to produce a high resolution file for customer delivery

This commit is contained in:
2019-11-15 12:59:14 -05:00
parent a4fcdd2629
commit 478b8be74f
3 changed files with 31 additions and 12 deletions

4
.gitignore vendored
View File

@@ -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

View File

@@ -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
View File