Make PDF Book
Make PDF Book is a JScript program that converts all of the JPEG images in the folder of the script into a single PDF document using ImageMagick. This script requires that ImageMagick be installed and able to be accessed as an object.
Source
// © Copyright: Dean Tersigni, 2017. // First Written: 2017-08-28 // Last updated: 2018-02-21 // // This script uses Imagemagick to convert all the files in the input into a single PDF document based on the alphabetical order of the input files. // // Options: // // sInput - The input file skeleton, for example "*.jpg" or "Test*.png" // sOutput - The file name of the final PDF. // iDPI - The DPI of the PDF page. 72 is the standard size for digital display. // iQualityPercent - What JPEG quality percentage the images should be set to. If -1, they will retain their current setting. // lForceSize - If true, all pages in the PDF will have a width and height matching iPageWidth and iPageHeight. Images larger than the specified dimensions will be cropped, smaller will get a white matte. // iPageWidth - The width of all of the pages in the PDF. Only used if lForceSize is set to true. // iPageHeight - The height of all of the pages in the PDF. Only used if lForceSize is set to true. var sInput = "*.jpg"; var sOutput = "Book.pdf"; var iDPI = 72; var iQualityPercent = -1; var lForceSize = false; var iPageWidth = -1; var iPageHeight = -1; var oIM = new ActiveXObject("ImageMagickObject.MagickImage.1"); if(lForceSize == true) { if(iQualityPercent == -1) { oIM.convert(sInput, "-gravity", "center", "-extent", iPageWidth.toString() + "x" + iPageHeight.toString(), "-density", iDPI.toString(), sOutput); } else { oIM.convert(sInput, "-gravity", "center", "-extent", iPageWidth.toString() + "x" + iPageHeight.toString(), "-quality", iQualityPercent.toString(), "-density", iDPI.toString(), sOutput); } } else { if(iQualityPercent == -1) { oIM.convert(sInput, "-gravity", "center", "-density", iDPI.toString(), sOutput); } else { oIM.convert(sInput, "-gravity", "center", "-quality", iQualityPercent.toString(), "-density", iDPI.toString(), sOutput); } }