• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Export letters as separate files

New Here ,
May 05, 2009 May 05, 2009

Copy link to clipboard

Copied

I'm working on a touchscreen interface, which includes a keyboard, and rather than modify and export each letter individually everytime I want to change the font or the style, I'd like to have a script do it for me. Basically it would open the file, replace the text content by a letter/number picked from a pre-defined set (while keeping layer styles intact) and then save for web.

This could also be useful when you need dropcaps or you want to use images instead of letters or numbers on a website.

It seems like a pretty common task so I was wondering if there's any script out there that already does it. If not, how hard do you think it would be to do ? I'm a newb to photoshop scripting but I know photoshop well, as well as javascript, so it shouldn't be too hard right ?

Thanks for the help !

TOPICS
Actions and scripting

Views

1.3K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe
Advisor ,
May 06, 2009 May 06, 2009

Copy link to clipboard

Copied

Sounds like a job for Datasets. Search PS Help.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
May 06, 2009 May 06, 2009

Copy link to clipboard

Copied

Thanks, I'll look into this. Actually I already succeeded in writing a script that does what I want, here it is:

var charArray=new Array(".","_","-",",","@","/","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","1","2","3","4","5","6","7","8","9","0")
var namesArray=new Array("dot","underscore","dash","coma","at","slash","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","1","2","3","4","5","6","7","8","9","0")


// Open file key.psd
var fileRef = File("myFile.psd")
var docRef = app.open(fileRef)
// Get character layer
var charLayerRef=app.activeDocument.artLayers.getByName("character")
// Set the contents of the text layer.
var textItemRef = charLayerRef.textItem
for(i=0;i<=charArray.length-1;i++){


textItemRef.contents = charArray

pngFile = new File( "/namesArray.png" )
app.activeDocument.saveAs(pngFile)

}

But I get an error 8080 with the saveAs function. In the end I just used the ScriptingListener plugin to record the code for "save as web" and this works fine, but I still wonder why the saveAs code (copied from the manual) doesn't work...

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
May 07, 2009 May 07, 2009

Copy link to clipboard

Copied

See if this works...

var charArray=new Array(".","_","-",",","@","/","a","b","c","d","e","f","g","h","i","j","k","l"," m","n","o","p","q","r","s","t","u","v","w","x","y","z","1","2","3","4","5","6"," 7","8","9","0");
var namesArray=new Array("dot","underscore","dash","coma","at","slash","a","b","c","d","e","f","g" ,"h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","1" ,"2","3","4","5","6","7","8","9","0");
// Open file key.psd
var fileRef = File("myFile.psd");
var docRef = app.open(fileRef);
// Get character layer
var charLayerRef=app.activeDocument.artLayers.getByName("character");
// Set the contents of the text layer.
var textItemRef = charLayerRef.textItem;
for(i=0;i<=charArray.length-1;i++){
textItemRef.contents = charArray;
//save in home folder
pngFile = new File( "~/namesArray.png" );
SavePNG(pngFile);
}

function SavePNG(saveFile){
    pngSaveOptions = new PNGSaveOptions();
    pngSaveOptions.embedColorProfile = true;
    pngSaveOptions.formatOptions = FormatOptions.STANDARDBASELINE;
    pngSaveOptions.matte = MatteType.NONE;
    pngSaveOptions.quality = 1;
pngSaveOptions.PNG8 = false; //24 bit PNG
    pngSaveOptions.transparency = true;
activeDocument.saveAs(saveFile, pngSaveOptions, true, Extension.LOWERCASE);
}

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
May 07, 2009 May 07, 2009

Copy link to clipboard

Copied

It works, thanks ! I don't know what that 8080 error means, but in any case it went away thanks to your code.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advisor ,
May 07, 2009 May 07, 2009

Copy link to clipboard

Copied

LATEST

8080 (and 8800) are generic error codes that PS uses when it can't tell you anything specific about what went wrong.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines