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

Save files as jpeg and close script

New Here ,
Nov 18, 2015 Nov 18, 2015

Copy link to clipboard

Copied

Hi all,

I am very new to scripting (as of this morning) and struggling to get my head round whether the following is possible. Apologies if I am missing something basic.

I would like to be able to have a script which will open a jpeg, insert the file name on to the image, save as a jpeg and close.

I have managed to find examples of this and currently have a script which will open the image, insert the file name and save the file - but as a photoshop document. I am also very keen on the images closing as I need to process at around 200 images at a time and and at the moment can only do a few at a time.

I have inserted what i have so far below...Any help would be appreciated.

/*

Description:

This script is a template script that will

open and process a folder of images

*/

// enable double clicking from the

// Macintosh Finder or the Windows Explorer

#target photoshop

// Make Photoshop the frontmost application

// in case we double clicked the file

app.bringToFront();

///////////////////////////

// SET-UP //

///////////////////////////

// A list of file extensions to skip, keep them lower case

gFilesToSkip = Array( "db", "xmp", "thm", "txt", "doc", "md0", "tb0", "adobebridgedb", "adobebridgedbt", "bc", "bct" );

// Pops open a dialog for the user to

// choose the folder of documents to process

var inputFolder = Folder.selectDialog("Select a folder of documents to process");

///////////////////////

// MAIN //

//////////////////////

// Open Folder of Images

OpenFolder();

// show the path to an output folder

alert(outputFolder);

///////////////////////////

// FUNCTIONS //

///////////////////////////

// Given the a Folder of files, open them

function OpenFolder() {

var filesOpened = 0;

var fileList = inputFolder.getFiles();

for ( var i = 0; i < fileList.length; i++ ) {

// Make sure all the files in the folder are compatible with PS

if ( fileList instanceof File && ! fileList.hidden && ! IsFileOneOfThese( fileList, gFilesToSkip )) {

open( fileList );

filesOpened++;

/////////////////////////////////////

// Put all your processing functions... //

/////////////////////////////////////

var originalUnits = app.preferences.rulerUnits

app.preferences.rulerUnits = Units.PIXELS

app.foregroundColor.rgb.red = 255

app.foregroundColor.rgb.green = 255

app.foregroundColor.rgb.blue = 255

// add the pixel position for the left side of your text block below

var textLeftPosition= 260

// add the pixel position for the bottom of your text block below

var textBottomPosition= 260

var typeLayer = app.activeDocument.artLayers.add();

typeLayer.name = app.activeDocument.name;

typeLayer.kind = LayerKind.TEXT;

typeLayer.textItem.size = 48;

typeLayer.textItem.position = [textLeftPosition, textBottomPosition];

var layerName = typeLayer.name

typeLayer.textItem.contents = layerName;

app.activeDocument.close(SaveOptions.SAVECHANGES);

}

////////////////////////////////////////////

// ...in the area between these two comments. //

////////////////////////////////////////////

}

}

// given a file name and a list of extensions

// determine if this file is in the list of extensions

function IsFileOneOfThese( inFileName, inArrayOfFileExtensions ) {

var lastDot = inFileName.toString().lastIndexOf( "." );

if ( lastDot == -1 ) {

return false;

}

var strLength = inFileName.toString().length;

var extension = inFileName.toString().substr( lastDot + 1, strLength - lastDot );

extension = extension.toLowerCase();

for (var i = 0; i < inArrayOfFileExtensions.length; i++ ) {

if ( extension == inArrayOfFileExtensions ) {

return true;

}

}

return false;

}

TOPICS
Actions and scripting

Views

573

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

correct answers 1 Correct answer

Community Expert , Nov 18, 2015 Nov 18, 2015

All you need do is create a little script to add the text layer.  Then record an action the uses that script.   You can the batch the action using menu File>Scripts>Image Processor.  In the image processor dialog point it to a folder containing your source image files. They can be jpg or any other image file type Photoshop supports. Point to a folder to save the jpg files to.  Set it to save JPG file (has an optional resize settings). Point it at your action set and the text adding action.

Capture.jpg

Votes

Translate

Translate
Adobe
Community Expert ,
Nov 18, 2015 Nov 18, 2015

Copy link to clipboard

Copied

All you need do is create a little script to add the text layer.  Then record an action the uses that script.   You can the batch the action using menu File>Scripts>Image Processor.  In the image processor dialog point it to a folder containing your source image files. They can be jpg or any other image file type Photoshop supports. Point to a folder to save the jpg files to.  Set it to save JPG file (has an optional resize settings). Point it at your action set and the text adding action.

Capture.jpg

JJMack

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 ,
Nov 19, 2015 Nov 19, 2015

Copy link to clipboard

Copied

LATEST

Amazing thank you! Works perfectly and much less complicated.

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