-
Notifications
You must be signed in to change notification settings - Fork 1
/
raj_catalog_page_slicer.jsx
56 lines (48 loc) · 1.6 KB
/
raj_catalog_page_slicer.jsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
// A quick proof of concept to automate site thumbnails
total_pages = 44;
catalog_season = "fall_2008";
full_document_path = "~/Documents/Repositories/decorbyraj.com/Assets/" + catalog_season + "/catalog_with_prices.pdf";
full_output_path = "~/Documents/Repositories/decorbyraj.com/Assets/" + catalog_season + "/jpg/with_prices/full/";
thumbs_output_path = "~/Documents/Repositories/decorbyraj.com/Assets/" + catalog_season + "/jpg/with_prices/thumbs/";
function open_document(page, type)
{
FileReference = new File(full_document_path);
PDFOpenOptions = new PDFOpenOptions();
PDFOpenOptions.page = page;
PDFOpenOptions.resolution = 72;
//if (type == "thumb")
//{
// PDFOpenOptions.width = 116;
// PDFOpenOptions.height = 150;
//}
app.open(FileReference, PDFOpenOptions);
}
function save_document(page, type)
{
if (type == "full")
{
jpgFile = new File(full_output_path + page + ".jpeg");
}
else
{
// CS3 has an adjusted resize process
width = new UnitValue(116, "px");
height = new UnitValue(150, "px");
app.activeDocument.resizeImage(width, height, 72, ResampleMethod.BICUBIC);
jpgFile = new File(thumbs_output_path + page + ".jpeg");
}
jpgSaveOptions = new JPEGSaveOptions();
jpgSaveOptions.embedColorProfile = true;
jpgSaveOptions.quality = 12;
app.activeDocument.saveAs(jpgFile, jpgSaveOptions, true, Extension.LOWERCASE);
}
function close_document()
{
app.activeDocument.close(SaveOptions.DONOTSAVECHANGES);
}
for (i=1; i<=total_pages; i++)
{
open_document(i, "thumb");
save_document(i, "thumb");
close_document();
}