From 478b8be74fa7103010bccb5b1eec108c91c931fa Mon Sep 17 00:00:00 2001 From: Jacob Cody Wimer Date: Fri, 15 Nov 2019 12:59:14 -0500 Subject: [PATCH] Added code to produce a high resolution file for customer delivery --- .gitignore | 4 +++- convert.py | 39 ++++++++++++++++++++++++++++----------- high-res/DELETE-ME.txt | 0 3 files changed, 31 insertions(+), 12 deletions(-) create mode 100644 high-res/DELETE-ME.txt diff --git a/.gitignore b/.gitignore index d9c13b7..29833bc 100644 --- a/.gitignore +++ b/.gitignore @@ -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 \ No newline at end of file +imagemagick.tar.gz diff --git a/convert.py b/convert.py index 6eb9188..5d081b7 100644 --- a/convert.py +++ b/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 + "\\" diff --git a/high-res/DELETE-ME.txt b/high-res/DELETE-ME.txt new file mode 100644 index 0000000..e69de29