Photoshop Script SaveAs Original

Post Reply
mkis
Member
Posts: 20
Joined: Fri Oct 21, 2011 3:19 pm
Location: Ahaus, Germany
Contact:

Photoshop Script SaveAs Original

Post by mkis »

Hello,

I have a problem with a photoshop script in the switch photoshop configurator.
I've included a script in the save method to save the image in the same file format as it comes in.
There is no other script or action selected.

When the script is executed the log says "Job processing successfully completed!" but the image will not go forward into the next folder.

Can somebody please help me with that?
Many Thanks!

Michael

----

Here's the script

Code: Select all


	try {
		$outfile = $outfolder + '/' + $filename + "." + $extension;
		$doc.save();
		$outfiles.push($outfile);
	}
	catch(theError) {
		$doc.close(SaveOptions.DONOTSAVECHANGES);
		$error = theError.description;
	}
	
freddyp
Advanced member
Posts: 413
Joined: Thu Feb 09, 2012 3:53 pm

Re: Photoshop Script SaveAs Original

Post by freddyp »

Two problems: you are not telling Photoshop to save the file to $outfile and $outfile is just a string, but the Photoshop documentation says to use a File object. The correct code (well, I have not tested it) should be like this:

Code: Select all

try {
      var $outfile = new File($outfolder + '/' + $filename + "." + $extension);
      $doc.save($outfile);		//perhaps you need SaveOptions as a 2nd parameter, but it is optional
      $outfiles.push($outfile);
   }
   catch(theError) {
      $doc.close(SaveOptions.DONOTSAVECHANGES);
      $error = theError.description;
   }
mkis
Member
Posts: 20
Joined: Fri Oct 21, 2011 3:19 pm
Location: Ahaus, Germany
Contact:

Re: Photoshop Script SaveAs Original

Post by mkis »

Hi Freddy,

thanks for your reply.

some parts of this script are from the Switch documentation "JavaScript for Applications"
http://www.enfocus.com/manuals/UserGuid ... /home.html

$outfiles ->
If your script is attached to a "save" action, it should set the contents of this array variable to the absolute paths of the output files generated by the script
The save() function doesn't need any parameters, it just saves the current document.
mkis
Member
Posts: 20
Joined: Fri Oct 21, 2011 3:19 pm
Location: Ahaus, Germany
Contact:

Re: Photoshop Script SaveAs Original

Post by mkis »

Freddy, you're right, it seems the documentation ist not up to date...
But I needed a .saveAs function, the .save won't work.

This code works now!

Code: Select all

var myDoc = $doc;
var $outfiles= [];

	try {
		var $outfile = new File($outfolder + '/' + $filename + "." + $extension);
		myDoc.saveAs($outfile);
		$outfiles.push($outfolder + '/' + $filename + "." + $extension);
	}
	catch(theError) {
		myDoc.close(SaveOptions.DONOTSAVECHANGES);
		$error = theError.description;
	}
Post Reply