Text on an indexed image?

Anyone, especially newbies, asking for help with Photoshop Scripting and Photoshop Automation - as opposed to those contributing to discussion about an aspect of Photoshop Scripting

Moderators: Tom, Kukurykus

DSanburn

Text on an indexed image?

Post by DSanburn »

I've been trying to figure out how to add text to an indexed image but I get the error: "The command MAKE is not currently available". I get this on the line: var newLayerRef = activeDocument.artLayers.add();

I am able to get it work using JavascriptListener but it sets every single variable available and I really just want a basic command sequence.

Any thoughts or ideas would be appreciated!
Thanks.
Andrew

Text on an indexed image?

Post by Andrew »

Try using this function, see if it works.

Code: Select all   function addTextLayer(layerName,text)
   {
      var thisLayer = activeDocument.artLayers.add();
      thisLayer.kind = LayerKind.TEXT;
      thisLayer.name = layerName;
      var textProperty = thisLayer.textItem;
      textProperty.size = 10;
      textProperty.font = "Arial";
      var newColor = new SolidColor();
      newColor.rgb.red = 0;
      newColor.rgb.green = 0;
      newColor.rgb.blue = 0;
      textProperty.color = newColor;
      textProperty.position = new Array( 20,20);
      thisLayer.blendMode = BlendMode.NORMAL;
      thisLayer.opacity = 100;
      textProperty.contents = text;
   }
   
   addTextLayer('test layer','test add text')


Andrew
DSanburn

Text on an indexed image?

Post by DSanburn »

Thanks for the reply! I copied your code and tried it out. I get the same error...make unavailable.

I probably should have mentioned earlier that I'm on PS7. That may not matter, but then again...they have done some very impressive scripting updates since this version.