-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathcontact-sheet-only.ts
754 lines (601 loc) · 23 KB
/
contact-sheet-only.ts
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
// try {
// /**********************************
// ** JUST CONTACT_SHEET
// ***********************************/
// let sourceDoc = app.activeDocument;
// //folder names
// let nameByDimensions = "sorted-by-type";
// let nameByIcon = "sorted-by-icon";
// let nameByColor = "sorted-by-color";
// let name300x300 = "300x300";
// let name512x512 = "512x512";
// let name64x64 = "64x64";
// let name48x48 = "48x48";
// let name32x32 = "32x32";
// let name24x24 = "24x24";
// let nameSVG = "SVG";
// let nameEPS = "EPS";
// // target icons for main loop
// let myIconsLayer = sourceDoc.layers["icons"];
// let myIconsSublayers = myIconsLayer.layers;
// // target colors for main loop
// let myColorsLayer = sourceDoc.layers["colors"];
// let myColorsSublayers = myColorsLayer.layers;
// let guideLayer = sourceDoc.layers["Guides (DO NOT MOVE)"];
// /**********************************
// ** INSTRUCTIONS DIALOG
// ***********************************/
// alert(
// "FULL README: https://github.com/Artchibald/WTW-illustrator-script \n\nVideo set up tutorial available here: https://youtu.be/9hrQIdJDNxY \n\nTHIS IS JUST THE CONTACT SHEET GENERATOR. \n\nThe main icons .ai template must be open and active. Not the contact-sheet.ai. \n\nYou can only run this script if you have run the other one first, Otherwise it won't work.\n\nWhen the contact sheet is ready to be generated, you can edit the rows and columns in the pop up. If you increase the columns, you should increase the rows, to avoid overlapping icons. The script will look in here: /sorted-by-type/SVG/ and generate the contact sheet from the .svg files saved there. Any issues: archie@archibaldbutler.com."
// );
// /**********************************
// ** CREATE CONTACT SHEET (2nd part of the script and separate, but relies on the above to work)
// ***********************************/
// let userInteractionLevel = UserInteractionLevel.DONTDISPLAYALERTS;;
// let originalInteractionLevel = userInteractionLevel;
// userInteractionLevel = UserInteractionLevel.DONTDISPLAYALERTS;
// let LANG = {
// CHOOSE_FOLDER: "Please choose your Folder of files to place...",
// NO_SELECTION: "No selection",
// LABEL_SETTINGS: "Contact Sheet Settings",
// LABEL_PG_WIDTH: "Page Width:",
// LABEL_PG_HEIGHT: "Page Height:",
// LABEL_COL_COUNT: "Column Count:",
// LABEL_ROW_COUNT: "Row Count:",
// LABEL_SCALE: "Scale:",
// LABEL_FILE_NAME: "File Name:",
// LABEL_LOGGING: "Logging?",
// BUTTON_CANCEL: "Cancel",
// BUTTON_OK: "Ok",
// DOES_NOT_EXIST: " does not exist",
// LAYER_NOT_CREATED: "Could not create layer. ",
// DOES_NOT_EXIT: "Does not exist"
// }
// let CONFIG = {
// NUM_ROWS: "",
// NUM_COLS: "",
// /**
// * Whether or not to add the file name as text
// * under the imported icons.
// */
// ADD_LABELS: true,
// /**
// * Number of rows
// */
// ROWS: 120,
// /**
// * Number of columns
// */
// COLS: 8,
// /**
// * Top & bottom page margins
// */
// VOFF: 64,
// /**
// * Left & Right page margins
// */
// HOFF: 64,
// /**
// * Row height. This is set programmatically.
// */
// ROW_WIDTH: 128,
// ROW_HEIGHT: 128,
// /**
// * Column Height. This is set programmatically.
// */
// COL_WIDTH: 128,
// /**
// * @deprecated
// */
// FRM_WIDTH: 128,
// /**
// * @deprecated
// */
// FRM_HEIGHT: 128,
// /**
// * Artboard width
// *
// * 10 columns 128 px wide, with 64 px page margins
// */
// PG_WIDTH: 1408,
// /**
// * Artboard height
// *
// * 20 rows 128 px tall, with 64 px page margins
// */
// PG_HEIGHT: 15360,
// PG_COUNT: 1,
// /**
// * Not yet fully-implemented. Will support multiple units
// */
// PG_UNITS: "px",
// /**
// * @deprecated
// */
// GUTTER: 0,
// /**
// * Enter scale in percentage 1-100
// */
// SCALE: 30,
// /**
// * Illustrator version compatibility
// */
// AIFORMAT: Compatibility.ILLUSTRATOR10,
// /**
// * If the icon is larger than the cell size, shrink it to the cell size
// */
// SHRINK_TO_FIT: true,
// /**
// * Start folder for selection
// */
// START_FOLDER: sourceDoc.path,
// /**
// * The contact sheet file name
// */
// FILENAME: "contact-sheet",
// /**
// * Enable logging?
// */
// LOGGING: true,
// /**
// * Log file location
// */
// LOG_FILE_PATH: sourceDoc.path + "/ai-contactsheet-log.txt",
// /**
// * Verbose logging output?
// */
// DEBUG: true,
// /**
// * @deprecated
// */
// SKIP_COLS: 0,
// /**
// * Not fully-implemented
// */
// STRIP: ["svg", "ai", "eps", "txt", "pdf"]
// }
// /**
// * Displays the settings dialog
// *
// * Inputs:
// * - skip columns
// * - page width
// * - page height
// * - cell width
// * - cell height
// * - scale
// * - logging enabled
// *
// * - number of cols = divide page width by cell width
// * - number of rows = divide page height by cell height
// * - side margins = (page width - (col count * col width))/2
// * - top/bottom margins = (page height - (row count * row width))/2
// *
// * @return Settings object
// */
// function doDisplayDialog() {
// let dialog = new Window("dialog", LANG.LABEL_SETTINGS, [550, 350, 900, 700] as Bounds) as any;
// let response = false;
// try {
// dialog.pageWidthLabel = dialog.add("statictext", [32, 30, 132, 60], LANG.LABEL_PG_WIDTH);
// dialog.pageWidth = dialog.add("edittext", [150, 30, 200, 60], CONFIG.PG_WIDTH);
// dialog.pageWidth.active = true;
// dialog.pageHeightLabel = dialog.add("statictext", [32, 70, 132, 100], LANG.LABEL_PG_HEIGHT);
// dialog.pageHeight = dialog.add("edittext", [150, 70, 200, 100], CONFIG.PG_HEIGHT);
// dialog.pageHeight.active = true;
// dialog.colsLabel = dialog.add("statictext", [32, 110, 132, 140], LANG.LABEL_COL_COUNT);
// dialog.cols = dialog.add("edittext", [150, 110, 200, 140], CONFIG.COLS);
// dialog.cols.active = true;
// dialog.rowsLabel = dialog.add("statictext", [32, 150, 132, 180], LANG.LABEL_ROW_COUNT);
// dialog.rows = dialog.add("edittext", [150, 150, 200, 180], CONFIG.ROWS);
// dialog.rows.active = true;
// dialog.scaleLabel = dialog.add("statictext", [32, 190, 132, 220], LANG.LABEL_SCALE);
// dialog.scale = dialog.add("edittext", [150, 190, 200, 220], CONFIG.SCALE);
// dialog.scale.active = true;
// dialog.filenameLabel = dialog.add("statictext", [32, 230, 132, 260], LANG.LABEL_FILE_NAME);
// dialog.filename = dialog.add("edittext", [150, 230, 320, 260], CONFIG.FILENAME);
// dialog.filename.active = true;
// dialog.logging = dialog.add('checkbox', [32, 270, 132, 340], LANG.LABEL_LOGGING);
// dialog.logging.value = CONFIG.LOGGING;
// dialog.cancelBtn = dialog.add("button", [80, 300, 170, 330], LANG.BUTTON_CANCEL, {
// name: "cancel"
// });
// dialog.openBtn = dialog.add("button", [180, 300, 270, 330], LANG.BUTTON_OK, {
// name: "ok"
// });
// dialog.cancelBtn.onClick = function () {
// dialog.close();
// response = false;
// return false;
// };
// dialog.openBtn.onClick = function () {
// CONFIG.PG_WIDTH = parseInt(dialog.pageWidth.text);
// CONFIG.PG_HEIGHT = parseInt(dialog.pageHeight.text);
// CONFIG.LOGGING = dialog.logging.value;
// CONFIG.SCALE = parseInt(dialog.scale.text);
// CONFIG.COLS = parseInt(dialog.cols.text);
// CONFIG.ROWS = parseInt(dialog.rows.text);
// CONFIG.COL_WIDTH = Math.floor((CONFIG.PG_WIDTH - (CONFIG.HOFF * 2)) / CONFIG.COLS);
// CONFIG.ROW_HEIGHT = Math.floor((CONFIG.PG_HEIGHT - (CONFIG.VOFF * 2)) / CONFIG.ROWS);
// CONFIG.FRM_WIDTH = CONFIG.COL_WIDTH;
// CONFIG.FRM_HEIGHT = CONFIG.ROW_HEIGHT;
// if (CONFIG.DEBUG) {
// logger("CONFIG.PG_WIDTH: " + CONFIG.PG_WIDTH);
// logger("CONFIG.PG_HEIGHT: " + CONFIG.PG_HEIGHT);
// logger("CONFIG.FRM_WIDTH: " + CONFIG.FRM_WIDTH);
// logger("CONFIG.FRM_HEIGHT: " + CONFIG.FRM_HEIGHT);
// logger("CONFIG.COL_WIDTH: " + CONFIG.COL_WIDTH);
// logger("CONFIG.ROW_HEIGHT: " + CONFIG.ROW_HEIGHT);
// logger("CONFIG.SCALE: " + CONFIG.SCALE);
// logger("CONFIG.ROWS: " + CONFIG.ROWS);
// logger("CONFIG.COLS: " + CONFIG.COLS);
// logger("CONFIG.VOFF: " + CONFIG.VOFF);
// logger("CONFIG.HOFF: " + CONFIG.HOFF);
// }
// dialog.close();
// response = true;
// return true;
// };
// dialog.show();
// } catch (ex) {
// logger(ex);
// alert(ex);
// }
// return response;
// }
// /**
// * Utility function to strip the file extension from a user-supplied file name
// * @param <string> filename
// * @return <string> The new file name sans extension
// */
// function stripFileExtension(filename) {
// let bits = filename.split(".");
// let bit = bits[bits.length - 1];
// let found = false;
// let ext;
// if (bits.length > 1 && bit) {
// for (ext in CONFIG.STRIP) {
// if (ext.toLowerCase() == bit.toLowerCase()) {
// found = true;
// }
// }
// }
// if (found) bits = bits[bits.length - 1] = "";
// return bits.join(".");
// }
// /**
// * Main logic to create the contact sheet.
// * @return void
// */
// function doCreateContactSheet() {
// let doc, fileList, svgFile,
// svgFilePath, allFiles,
// theFolders, svgFileList, theLayer;
// let saveCompositeFile = false;
// let srcFolder = Folder(`${sourceDoc.path}/${nameByDimensions}/${nameSVG}`);
// if (srcFolder != null) {
// allFiles = srcFolder.getFiles();
// theFolders = [];
// for (let x = 0; x < allFiles.length; x++) {
// if (allFiles[x] instanceof Folder) {
// theFolders.push(allFiles[x]);
// }
// }
// svgFileList = [];
// if (theFolders.length == 0) {
// svgFileList = srcFolder.getFiles(/\.svg$/i);
// } else {
// for (let x = 0; x < theFolders.length; x++) {
// // Gets just the SVG files...
// fileList = theFolders[x].getFiles(/\.svg$/i);
// for (let n = 0; n < fileList.length; n++) {
// svgFileList.push(fileList[n]);
// }
// }
// }
// if (svgFileList.length > 0) {
// if (!doDisplayDialog()) {
// return;
// }
// if (CONFIG.FILENAME.replace(" ", "") == "") {
// CONFIG.FILENAME = srcFolder.name.replace(" ", "-") + "-all";
// }
// // CONFIG.FILENAME = stripFileExtension(CONFIG.FILENAME);
// app.coordinateSystem = CoordinateSystem.ARTBOARDCOORDINATESYSTEM;
// doc = app.documents.add(
// DocumentColorSpace.RGB,
// CONFIG.PG_WIDTH,
// CONFIG.PG_HEIGHT,
// CONFIG.PG_COUNT = Math.ceil(svgFileList.length / (CONFIG.ROWS * CONFIG.COLS)),
// DocumentArtboardLayout.GridByCol,
// CONFIG.GUTTER,
// Math.round(Math.sqrt(Math.ceil(svgFileList.length / (CONFIG.ROWS * CONFIG.COLS))))
// );
// for (let i = 0; i < svgFileList.length; i++) {
// let y1;
// let y2;
// let x2;
// let board;
// let bounds;
// let x1 = y1 = x2 = y2 = 0;
// let myRowHeight = CONFIG.ROW_HEIGHT + CONFIG.GUTTER;
// let myColumnWidth = CONFIG.COL_WIDTH + CONFIG.GUTTER
// let myFrameWidth = CONFIG.FRM_WIDTH
// let myFrameHeight = CONFIG.FRM_HEIGHT
// for (let pageCounter = CONFIG.PG_COUNT - 1; pageCounter >= 0; pageCounter--) {
// let boardWidth;
// doc.artboards.setActiveArtboardIndex(pageCounter);
// board = doc.artboards[pageCounter];
// bounds = board.artboardRect;
// boardWidth = Math.round(bounds[2] - bounds[0]);
// // loop through rows
// let rowCount = Math.ceil((svgFileList.length / CONFIG.COLS));
// rowCount = CONFIG.ROWS > rowCount ? rowCount : CONFIG.ROWS;
// // If we are skipping a column, chances are we need to
// // add a new row for the overflow of the shift. Even if there
// // is not a new row needed, there are no consequences for
// // adding one, so just in case.
// if (CONFIG.SKIP_COLS > 0) {
// rowCount++;
// }
// let myY1;
// let myY2;
// for (let rowCounter = 1; rowCounter <= rowCount; rowCounter++) {
// myY1 = bounds[1] + CONFIG.VOFF + (myRowHeight * (rowCounter - 1));
// myY2 = myY1 + CONFIG.FRM_HEIGHT;
// // loop through columns
// let colCount = CONFIG.COLS;
// if (rowCounter > 1) {
// let remaining = Math.ceil(svgFileList.length - i);
// if (remaining < colCount) {
// colCount = remaining;
// }
// }
// for (let columnCounter = 1; columnCounter <= colCount; columnCounter++) {
// try {
// // A hack to allow merging multiple contact sheets
// // Shift the starting row so it aligns nicely with
// // the icons already in the master contact sheet.
// if (CONFIG.SKIP_COLS > 0 && rowCounter == 1 && columnCounter <= CONFIG.SKIP_COLS) {
// continue;
// }
// let f = new File(svgFileList[i]);
// if (f.exists) {
// try {
// if (i == 0) {
// theLayer = doc.layers[0];
// } else {
// theLayer = doc.layers.add();
// }
// theLayer.name = f.name;
// } catch (ex) {
// logger(LANG.LAYER_NOT_CREATED + ex);
// }
// svgFile = doc.groupItems.createFromFile(f);
// let liveWidth = (CONFIG.COLS * (CONFIG.FRM_WIDTH + CONFIG.GUTTER)) - CONFIG.GUTTER;
// let hoff = Math.ceil((CONFIG.PG_WIDTH - liveWidth) / 2);
// let myX1;
// let myX2;
// myX1 = bounds[0] + hoff + (myColumnWidth * (columnCounter - 1));
// myX2 = myX1 + CONFIG.FRM_HEIGHT;
// let shiftX = Math.ceil((CONFIG.FRM_WIDTH - svgFile.width) / 2);
// let shiftY = Math.ceil((CONFIG.FRM_WIDTH - svgFile.height) / 2);
// x1 = myX1 + shiftX;
// y1 = (myY1 + shiftY) * -1;
// try {
// svgFile.position = [x1, y1];
// if (typeof (svgFile.resize) == "function") {
// svgFile.resize(CONFIG.SCALE, CONFIG.SCALE);
// }
// if (CONFIG.ADD_LABELS) {
// // f.name.toString().replace(/\%20/g, " "); //change %20 to spaces
// // f.name.toString().replace(/\.[^\.]*$/, ""); //remove extension
// // theLayer.name = theLayer.name.toString().replace(/\%20/g, " "); //change %20 to spaces
// // theLayer.name = theLayer.name.toString().replace(/\.[^\.]*$/, ""); //remove extension
// addLabel(theLayer, [x1 - (svgFile.width - 165), y1 - (svgFile.height + 100)], f.name.toString().replace(/\.[^\.]*$/, "").toString().replace(/\--SVG/g, "").replace(/\%20/g, " "))
// }
// // Only save the composite file if at least one
// // icon exists and is successfully imported.
// saveCompositeFile = true;
// redraw();
// } catch (ex) {
// try {
// svgFile.position = [0, 0];
// logger(ex);
// } catch (ex) {
// /*Exit Gracefully*/
// }
// }
// } else {
// logger(svgFileList[i] + LANG.DOES_NOT_EXIT);
// }
// } catch (ex) {
// logger(ex);
// alert(ex);
// }
// i++;
// }
// }
// };
// if (saveCompositeFile)
// saveFileAsAi(sourceDoc.path + "/" + CONFIG.FILENAME);
// }
// };
// };
// };
// /**
// * Arranges items in the selection on a grid
// * @param <selection> sel The current selection
// * @return void
// */
// function arrangeItems(sel) {
// let theItem;
// let rows;
// let doc;
// let y1;
// let board;
// let bounds;
// let itemBounds;
// let cols;
// let cellSize;
// let x1 = y1 = 0;
// let boardWidth, boardHeight;
// board = doc.artboards[doc.artboards.getActiveArtboardIndex()];
// bounds = board.artboardRect;
// boardWidth = Math.round(bounds[2] - bounds[0]);
// cols = CONFIG.NUM_COLS;
// rows = CONFIG.NUM_ROWS;
// x1 = bounds[0] + cellSize;
// y1 = bounds[1] - cellSize;
// for (let i = 0, slen = sel.length; i < slen; i++) {
// theItem = sel[i];
// itemBounds = theItem.visibleBounds;
// theItem.top = y1 - ((cellSize - theItem.height) / 2);
// theItem.left = x1 + ((cellSize - theItem.width) / 2);
// alignToNearestPixel(theItem);
// x1 += cellSize;
// if (i % cols == cols - 1) {
// x1 = bounds[0] + cellSize;
// y1 -= cellSize;
// }
// }
// if (CONFIG.SHRINK_TO_FIT) {
// // The bounds are plotted on a Cartesian Coordinate System.
// // So a 32 x 32 pixel artboard with have the following coords:
// // (assumes the artboard is positioned at 0, 0)
// // x1 = -16, y1 = 16, x2 = 16, y2 = -16
// // board.artboardRect = [x1, y1, x2, y2];
// board.artboardRect = [
// bounds[0],
// bounds[1],
// bounds[0] + ((cols * cellSize) + (2 * cellSize)),
// bounds[1] - (rows * cellSize)
// ];
// }
// };
// /**
// * Places a text label
// * @param {string} text
// * @param {string} pos - The X/Y position of the label
// * @param {string} size - The text content of the label
// * @returns void
// */
// function addLabel(layer, pos, theText) {
// try {
// let theLabel = layer.textFrames.add();
// theLabel.contents = theText;
// let charAttributes = theLabel.textRange.characterAttributes;
// let parAttributes = theLabel.paragraphs[0].paragraphAttributes;
// charAttributes.size = 7;
// parAttributes.justification = Justification.CENTER;
// theText = theText.toString().replace(/\%20/g, " "); //change %20 to spaces
// theText = theText.toString().replace(/\.[^\.]*$/, ""); //remove extension
// try {
// theLabel.position = pos;
// } catch (e) {
// alert('labelPosition : ' + e)
// }
// return theLabel;
// } catch (e) {
// alert('addLabel : ' + e)
// }
// }
// /**
// * Saves the file in AI format.
// * @param <string> The file destination path
// * @return void
// */
// function saveFileAsAi(dest) {
// if (app.documents.length > 0) {
// let options = new IllustratorSaveOptions();
// let theDoc = new File(dest);
// IllustratorSaveOptions.compatibility = CONFIG.AIFORMAT;
// IllustratorSaveOptions.flattenOutput = OutputFlattening.PRESERVEAPPEARANCE;
// IllustratorSaveOptions.pdfCompatible = true;
// app.activeDocument.saveAs(theDoc, options);
// }
// }
// function redraw() { }
// /**
// * Aligns selection to nearest whole pixel
// * @param <selection> sel The selection object
// * @return void
// */
// function alignToNearestPixel2(sel) {
// try {
// if (typeof sel != "object") {
// logger(LANG.NO_SELECTION);
// } else {
// let i;
// for (i = 0; i < sel.length; i++) {
// sel[i].left = Math.round(sel[i].left);
// sel[i].top = Math.round(sel[i].top);
// }
// redraw();
// }
// } catch (ex) {
// logger(ex);
// }
// }
// /**
// * Logging for this script.
// * @param <string> The logging text
// * @return void
// */
// function logger(txt) {
// if (CONFIG.LOGGING == true) return;
// let file = new File(CONFIG.LOG_FILE_PATH);
// file.open("e", "TEXT", "????");
// file.seek(0, 2);
// $.os.search(/windows/i) != -1 ? file.lineFeed = 'windows' : file.lineFeed = 'macintosh';
// file.writeln("[" + new Date().toUTCString() + "] " + txt);
// file.close();
// }
// /**
// * Aligns the item to the nearest pixel for crisp rendering.
// * @param <object> item The item to align
// * @return void
// */
// function alignToNearestPixel(item) {
// if (item.height) {
// item.height = moveToPixel(item.height);
// }
// if (item.width) {
// item.width = moveToPixel(item.width);
// }
// item.top = moveToPixel(item.top);
// item.left = moveToPixel(item.left);
// };
// /**
// * Adjusts a value to the nearest whole number
// * @param <float> n The value to adjust
// * @return <int>
// */
// function moveToPixel(n) {
// return Math.round(n)
// };
// doCreateContactSheet();
// // Crop to selection with gutters!
// let offset = 10 * 2.83465;
// sourceDoc.selection = null;
// let idx = sourceDoc.artboards.getActiveArtboardIndex();
// sourceDoc.selectObjectsOnActiveArtboard();
// sourceDoc.fitArtboardToSelectedArt(idx); // does not work for visible bounds of editable fonts
// let rect = sourceDoc.artboards[idx].artboardRect;
// sourceDoc.artboards[idx].artboardRect = [rect[0] - offset, rect[1] + offset, rect[2] + offset, rect[3] - offset];
// sourceDoc.selection = null;
// // unselect everything
// userInteractionLevel = originalInteractionLevel;
// app.activeDocument.save();
// // close the document here without saving, uncomment for prod
// // app.activeDocument.close(SaveOptions.DONOTSAVECHANGES);
// //photoshop
// //app.system(terminalCommand)
// // close the document here without saving, uncomment for prod
// // app.activeDocument.close(SaveOptions.DONOTSAVECHANGES);
// //photoshop
// //app.system(terminalCommand)
// //photoshop
// }
// catch {
// }