Skip to main content
Participant
May 18, 2023
Question

How to save clipboard image into local folder as jpeg in extendscript

  • May 18, 2023
  • 2 replies
  • 849 views

Hi,

 

Can you please provide the Extendacript code to save clipboard image into local system/folder.

I want to save clipboard image inot my local machine so please provide the extendscript code/javascript code

 

Thank You..!!

This topic has been closed for replies.

2 replies

jduncan
Community Expert
Community Expert
May 18, 2023

So this is hacky at best but it works with images copied to your system clipboard. Tested with copying images from a website and from within the Preview app on a Mac. Screencast video shows the script in action.

// make a new document and paste the image
var doc = app.documents.add(DocumentColorSpace.RGB);
app.executeMenuCommand("paste");
var img = doc.pageItems[0];

// resize the artboard to match the image size
app.executeMenuCommand("Fit Artboard to artwork bounds");

// setup export file info
var fpath = Folder.desktop + "/EXAMPLE/"; // folder where JPEG will be saved
var fname = "imageExport.jpeg"; // name of saved JPEG
var f = new File(fpath + "/" + fname);

// export the file as a JPEG
var exportOptions, exportType;
exportOptions = new ExportOptionsJPEG();
exportOptions.qualitySetting = 100;
doc.exportFile(f, ExportType.JPEG, exportOptions);

 

Community Expert
May 18, 2023

I don't think you will be able to do this directly using Extendscript. You might have to use OS scripting i.e. Applescript on MAC and VBScript on WIN.

-Manan

-Manan