打开文件夹中的所有pdf文件,并保存为调整大小的jpg在其他文件夹
Open all pdf files in folder and save as resized jpgs in other folder
我有一个脚本,检查图像是否比250px宽,如果它比300px高,如果这些语句中的任何一个是真的,它应该调整它们的大小以适应这两个值。然后,它应该将它们保存为jpg,扩展名为large的文件夹中的文件名。然而,我不知道如何使photoshop打开所有文件在一个给定的文件夹和执行脚本,我也不知道如何正确地导出它们,photoshop停止时,它试图导出。
下面是我的代码:// get a reference to the current (active) document and store it in a variable named "doc"
doc = app.activeDocument;
// change the color mode to RGB. Important for resizing GIFs with indexed colors, to get better results
doc.changeMode(ChangeMode.RGB);
// these are our values for the END RESULT width and height (in pixels) of our image
var fWidth = 250;
var fHeight = 300;
// do the resizing. if height > width (portrait-mode) resize based on height. otherwise, resize based on width
if (doc.height > 300) { doc.resizeImage(null,UnitValue(fHeight,"300"),null,ResampleMethod.BICUBIC); }
else if (doc.width > 250) { doc.resizeImage(null,UnitValue(fWidth,"250"),null,ResampleMethod.BICUBIC); }
// Makes the default background white
var white = new SolidColor();
white.rgb.hexValue = "FFFFFF";
app.backgroundColor = white;
// Convert the canvas size as informed above for the END RESULT app.activeDocument.resizeCanvas(UnitValue(fWidth,"px"),UnitValue(fHeight,"px"));
// our web export options
var options = new ExportOptionsSaveForWeb();
options.quality = 70;
options.format = SaveDocumentType.JPEG;
options.optimized = true;
var newName = 'web-'+doc.name+'.jpg';
doc.exportDocument(File(doc.path+'/images/'+newName);
打开PDF文件有点困难。正如我在几周前的请求中所述:Photoshop JavaScript:打开PDF作为智能对象的选项
我的解决办法是使用一个动作(从动作面板)打开文件(模态控制,设置有效的PDF渲染),并启动脚本。
您可以使用该操作导出为web JPG。
如果您想使用脚本,File
需要一个完整的路径。
var destFile = new File ("~/Desktop/" + "web-" + doc.name + ".jpg");
还需要exportDocument
的参数(非可选)。
doc.exportDocument(destFile, ExportType.SAVEFORWEB, options);
相关文章:
- 如何在android中使用phonegap将文件从一个文件夹移动/复制到另一个文件夹
- 如何将乳胶配方奶粉图像保存到Asp.net中的文件夹中
- 展开和折叠文件夹
- 在ng重复循环中显示来自不同文件夹的图像
- 如何将所有JS文件连接到一个文件夹中
- 是否可以用JavaScript显示等效的文件夹对话框
- grunt上的压缩文件夹不起作用
- 如何使用javascript获取从指定文件夹创建的所有文件的名称、大小、类型和日期
- 将Windows文件路径组织到文件夹中
- 链接/按钮从子文件夹下载文件--浏览器只是浏览
- 在更改名称时,使用ajax jsp在下拉菜单中填充多个文件夹的数据
- 我应该将MVC视图特定的javascript文件放在哪个文件夹中
- 如何将JS文件从其他文件夹链接到页面
- 将文件从应用程序文件夹复制到JQM/Phonegap应用程序中的根文件夹
- 在以前的文件夹中加载脚本
- 如何在ExtJs4应用程序上为视图、存储和模型设置自定义文件夹名称
- AngularJS-如何列出给定文件夹中的文件名
- 如何通过资产管道提供Javascript中子文件夹中的图像
- Photoshop 脚本 - 调整文件夹中的图像大小(对话框)
- 打开文件夹中的所有pdf文件,并保存为调整大小的jpg在其他文件夹