如何通过Photoshop API Action JSON适配图片至指定尺寸?
解决Photoshop API适配图片指定尺寸的问题
你使用的javaScriptOptionsClass并非实现图片尺寸适配的正确对象,Photoshop API的Action JSON需要通过fitImage操作来完成指定尺寸的图片适配。以下是正确的配置示例:
正确的Action JSON适配配置
{ "_obj": "fitImage", "_target": [{"_ref": "document", "_enum": "ordinal", "_value": "targetEnum"}], "width": {"_unit": "pixelsUnit", "_value": 1080.0}, "height": {"_unit": "pixelsUnit", "_value": 1440.0}, "constrainProportions": false, "resampleMethod": {"_enum": "resampleMethod", "_value": "bicubicAutomatic"} }
参数说明
_obj: "fitImage":明确指定执行图片尺寸适配操作_target:定位到当前操作的目标文档width/height:设置目标宽高,单位为像素constrainProportions:设为false可强制适配指定宽高;若需保持原图比例,设为true即可resampleMethod:设置重采样算法,bicubicAutomatic是Photoshop默认的自动优化算法,也可替换为bilinear、nearestNeighbor等其他算法
将上述配置放入Action JSON的_commands数组中,与其他操作一起提交至https://image.adobe.io/pie/psdService/actionJSON端点即可生效。
内容的提问来源于stack exchange,提问作者Rasmus Lian
相关产品推荐
相关产品推荐

