论坛帮助 |
社区圈子 |
日历事件 |
2024-09-20, 14:37 | #1 | ||
|
|||
正式会员
等级: 小兄弟
|
我小白一个,仅仅将脚本修改成也支持eps 的格式,目前输出的PNG图片都很小 ,请求论坛重点高手能不能帮忙完善下, 添加 可以设置限定输出PNG像素的代码, 比如宽1000px, 如果能改成输出宽1000px的JPG也可以, 再次感谢帮忙的各位大神。 脚本代码如下: // Required modules var Folder = Folder, File = File, ExportOptionsPNG24 = ExportOptionsPNG24, app = app; // Select source folder containing EPS files var sourceFolder = Folder.selectDialog("Select the source folder"); if (sourceFolder) { // Select destination folder for PNG files var destFolder = Folder.selectDialog("Select the destination folder"); if (destFolder) { // Process EPS files processFiles(); } } // Function to process EPS files function processFiles() { var files = sourceFolder.getFiles("*.eps"); for (var i = 0; i < files.length; i++) { if (files[i] instanceof File && files[i].name.indexOf(".eps") !== -1) { convertToPNG(files[i]); $.sleep(2000); // Add a delay of 1 second before processing the next file } } alert("Conversion complete!"); } // Function to convert EPS file to PNG function convertToPNG(file) { var doc = app.open(file); // Set PNG export options var exportOptions = new ExportOptionsPNG24(); exportOptions.artBoardClipping = true; exportOptions.transparency = true; // Set destination file var destFile = new File(destFolder + "/" + file.name.replace(".eps", ".png")); // Export the document as PNG doc.exportFile(destFile, ExportType.PNG24, exportOptions); // Close the document doc.close(SaveOptions.DONOTSAVECHANGES); } ---------------------------------------------------------------- 脚本下载:EPStoPNGs.zip |
||
回复时引用此帖 |
2024-09-20, 16:11 | 只看该作者 #2 | ||
|
|||
正式会员
等级: 小兄弟
|
---------------------------------------------- /** * IllustratorBulkExporter.jsx * Easily "Export for web" in a lot of dimensions at a time * https://github.com/chteuchteu/Illust...lkExporter.jsx * Quentin Stoeckel <stoeckel.quentin@gmail.com> */ var options = { dimensions: [ 1024 ], fileName: 'icon-{}x{}.png' }; var CustomExporter = function(options) { this.options = options; }; CustomExporter.prototype = { doExport: function() { var self = this; this.folder = Folder.selectDialog(); this.document = app.activeDocument; if (!this.document || !this.folder) throw new Error("Invalid folder or document."); for (var i=0; i<this.options.dimensions.length; i++) { var dimension = this.options.dimensions[i]; var fileName = self.options.fileName.split('{}').join(dimension); self.saveToRes(dimension, fileName); } }, saveToRes: function(scaleTo, fileName) { scaleTo = scaleTo/this.document.width*100.0; var layer, resFolder; if (fileName.indexOf('/') != -1) { // Create subdirectory var subdir = fileName.substr(0, fileName.indexOf('/')); resFolder = new Folder(this.folder.fsName + '/' + subdir); fileName = fileName.substr(t.indexOf('/')+1); } else resFolder = this.folder; if (!resFolder.exists) resFolder.create(); for (var i = this.document.layers.length - 1; i >= 0; i--) { layer = this.document.layers[i]; if (!layer.locked && layer.name.indexOf("!") === -1) { this.hideAllLayers(); layer.visible = true; var file = new File(resFolder.fsName+ "/" + fileName); var options = new ExportOptionsPNG24(); options.antiAliasing = true; options.transparency = true; options.artBoardClipping = true; options.verticalScale = scaleTo; options.horizontalScale = scaleTo; this.document.exportFile(file, ExportType.PNG24, options); } } }, hideAllLayers: function() { for (var i = this.document.layers.length - 1; i >= 0; i--) { var layer = this.document.layers[i]; if (!layer.locked && layer.name.indexOf("!") === -1) { layer.visible = false; } } } }; var exporter = new CustomExporter(options); exporter.doExport(); |
||
回复时引用此帖 |