Skip to main content
daniell11223644
Known Participant
August 30, 2020
Answered

activeDocument.saveAs issues

  • August 30, 2020
  • 1 reply
  • 701 views

I am trying to save a tif file via script. The generated value for filename is /d/RAW%20Compare/teststack/Untitled-1_02_45_48.tif. The filename is generated, and the path was generated by using var folder = new Folder('D:/RAW Compare/teststack'); and adding filename to the end of it.

 

The Error I get is Error 1242: Illegal argument - argument 1

- File/Folder expected

 

 

function saveTiff(filename){
	tiffSaveOptions = new TiffSaveOptions();   
	tiffSaveOptions.embedColorProfile = true;   
	tiffSaveOptions.alphaChannels = true;   
	tiffSaveOptions.layers = true;  
	tiffSaveOptions.imageCompression = TIFFEncoding.NONE;  
	activeDocument.saveAs(filename, tiffSaveOptions, true, Extension.LOWERCASE);   
}

 

 

 

 

 

I get Error 24: file is not a function when I try to use the following

 

 

	activeDocument.saveAs(file(filename), tiffSaveOptions, true, Extension.LOWERCASE);   

 

 

edit:

Changing the function to the following helped make it work

function saveTiff(filename){
	tiffFile = new File(filename);
	tiffSaveOptions = new TiffSaveOptions();   
	tiffSaveOptions.embedColorProfile = true;   
	tiffSaveOptions.alphaChannels = true;   
	tiffSaveOptions.layers = true;  
	tiffSaveOptions.imageCompression = TIFFEncoding.NONE;  
	//alert(filename);
	activeDocument.saveAs(tiffFile, tiffSaveOptions, true, Extension.LOWERCASE);   
}
This topic has been closed for replies.
Correct answer Charu Rajput

Hi,

I get Error 24: file is not a function when I try to use the following

For this, use File (F is capital not small)

activeDocument.saveAs(File(filename), tiffSaveOptions, true, Extension.LOWERCASE);

Let us know if this works for you.

1 reply

Charu Rajput
Community Expert
Charu RajputCommunity ExpertCorrect answer
Community Expert
August 30, 2020

Hi,

I get Error 24: file is not a function when I try to use the following

For this, use File (F is capital not small)

activeDocument.saveAs(File(filename), tiffSaveOptions, true, Extension.LOWERCASE);

Let us know if this works for you.

Best regards
daniell11223644
Known Participant
August 30, 2020

I think I tried it, but it didnt wotk and I didnt to make a new filename = new File(otherfilename); to get it to work.

Charu Rajput
Community Expert
Community Expert
August 30, 2020

Hi,

The above answer is same as filename = new File(otherfilename);

You can use any of the way. Just make sure F should be in uppercase for file.

Best regards