【问题标题】:Photoshop: Batch auto-create 100s of shapes changing color from a TXT listPhotoshop:从 TXT 列表中批量自动创建 100 个改变颜色的形状
【发布时间】:2021-12-30 23:45:33
【问题描述】:

我正在为下一步如何自动化和批处理而摸不着头脑。

我想自动创建许多 png 文件,填充形状的颜色并从列表中命名。

我制作了我的 psd 模板(矩形), 并有以下 txt 列表(制表符分隔)+300 项, 包含要填充的颜色十六进制值,以及要创建的图像的名称。

+--------+-----------+
| HEX    | name      |
+--------+-----------+
| 003366 | A1_003366 |
+--------+-----------+
| 9AB0C7 | B1_9AB0C7 |
+--------+-----------+
| FFFFE5 | A2_FFFFE5 |
+--------+-----------+
| F9F9F3 | B2_F9F9F3 |
+--------+-----------+
| DC143C | A3_DC143C |
+--------+-----------+
| 006866 | B3_006866 |
+--------+-----------+

我希望我的 png 文件命名并带有相应的颜色。比如:

A1_003366.png
B1_9AB0C7.png
A2_FFFFE5.png
and so on

我尝试使用变量,但看不到如何更改要创建的每个图像的颜色和名称。 Photoshop可以做到这一点吗?

非常感谢您的帮助。

【问题讨论】:

  • 您提到的形状在哪里定义?它们是三角形、正方形还是圆形? A1前缀和B3前缀从何而来?这个列表应该产生什么?您使用的是什么操作系统?

标签: variables action batch-processing photoshop batch-rename


【解决方案1】:

认为您正在寻找一种更改活动形状颜色的方法,在这种情况下,您可以使用此脚本侦听器代码:

var myHex = "003366";

//alert(hex_to_dec(myHex));
fill_rectangle(hex_to_dec(myHex));

function hex_to_dec(hexstring)
{
   var hex = hexstring.match(/.{1,2}/g);
   return [
       parseInt(hex[0], 16),
       parseInt(hex[1], 16),
       parseInt(hex[2], 16)
   ]
}

function fill_rectangle(rgb)
{
   var red   = rgb[0];
   var green = rgb[1];
   var blue  = rgb[2];
   // =======================================================
   var idsetd = charIDToTypeID( "setd" );
   var desc23 = new ActionDescriptor();
   var idnull = charIDToTypeID( "null" );
   var ref3 = new ActionReference();
   var idcontentLayer = stringIDToTypeID( "contentLayer" );
   var idOrdn = charIDToTypeID( "Ordn" );
   var idTrgt = charIDToTypeID( "Trgt" );
   ref3.putEnumerated( idcontentLayer, idOrdn, idTrgt );
   desc23.putReference( idnull, ref3 );
   var idT = charIDToTypeID( "T   " );
   var desc24 = new ActionDescriptor();
   var idFlCn = charIDToTypeID( "FlCn" );
   var desc25 = new ActionDescriptor();
   var idClr = charIDToTypeID( "Clr " );
    var desc26 = new ActionDescriptor();
    var idRd = charIDToTypeID( "Rd  " );
    desc26.putDouble( idRd, red ); //red
    var idGrn = charIDToTypeID( "Grn " );
    desc26.putDouble( idGrn, green ); //green
    var idBl = charIDToTypeID( "Bl  " );
    desc26.putDouble( idBl, blue ); //blue
   var idRGBC = charIDToTypeID( "RGBC" );
   desc25.putObject( idClr, idRGBC, desc26 );
   var idsolidColorLayer = stringIDToTypeID( "solidColorLayer" );
   desc24.putObject( idFlCn, idsolidColorLayer, desc25 );
   var idstrokeStyle = stringIDToTypeID( "strokeStyle" );
   var desc27 = new ActionDescriptor();
   var idstrokeStyleVersion = stringIDToTypeID( "strokeStyleVersion" );
   desc27.putInteger( idstrokeStyleVersion, 2 );
   var idfillEnabled = stringIDToTypeID( "fillEnabled" );
   desc27.putBoolean( idfillEnabled, true );
   var idstrokeStyle = stringIDToTypeID( "strokeStyle" );
   desc24.putObject( idstrokeStyle, idstrokeStyle, desc27 );
   var idshapeStyle = stringIDToTypeID( "shapeStyle" );
   desc23.putObject( idT, idshapeStyle, desc24 );
   executeAction( idsetd, desc23, DialogModes.NO );
}

【讨论】:

  • 您的代码确实符合我的要求。如何让脚本加载txt文件并生成所需的+300 png文件? “C:\Desktop\colors\list.txt” 看起来我想要的有点复杂。无论如何,我感谢你的帮助。
  • StackOverflow 不是脚本编写服务。您的问题的答案可以在互联网上找到。看看this 忽略excel和卡片部分。查看读取 (readIt) 函数让 Photoshop 读取文本文件
猜你喜欢
  • 2016-10-19
  • 2017-01-24
  • 2011-11-02
  • 2019-01-29
  • 2014-08-11
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多