I want the exported pictures to use the artboard's size. Thanks in advance.
var folder = Folder.selectDialog(); var document = app.activeDocument; if(document && folder) { var options = new ExportOptionsJPEG(); options.antiAliasing = true; options.qualitySetting = 100; options.optimization = true; options.croppingMaskClipping = true; //scale to 500dpi options.verticalScale = 500; options.horizontalScale = 500; var n = document.layers.length; for(var i=0; i<n; ++i) { hideAllLayers(); var layer = document.layers[i]; layer.visible = true; var file = new File(folder.fsName+"/"+layer.name+".jpg"); document.exportFile(file,ExportType.JPEG,options); } //to show all layers visible when done: showAllLayers(); } function hideAllLayers() { forEach(document.layers, function(layer) { /** if there is one or more layers called 'ABC' in the .ai file, it will always be part of the export. */ if( layer.name != "ABC"){ layer.visible = false; } }); } function showAllLayers() { forEach(document.layers, function(layer) { layer.visible = true; }); } function forEach(collection, fn) { var n = collection.length; for(var i=0; i<n; ++i) { fn(collection[i]); } }