Skip to main content
Participating Frequently
September 17, 2020
Beantwortet

Droplet with prefix in original folder

  • September 17, 2020
  • 1 Antwort
  • 1518 Ansichten

Hello,

I would like to create a droplet to change the size of the image but also to save the new file with a prefix.

picture.jpg> droplet> size change> save file change with the WEB- prefix.

picture.jpg (original)
WEB-picture.jpg (size changed)

I would like this file to be saved in the original folder and not in a fixed folder.

The pb is that to integrate a fixed prefix, I need, in the droplat option, to choose a folder.

Do you know if I can get around this restriction?

thank you so much

Dieses Thema wurde für Antworten geschlossen.
Beste Antwort von c.pfaffenbichler

Indeed, I understand better now. I'm almost there, I integrated the script into an action that I would convert to a droplet afterwards.
On the other hand, I have a pb is that it asks me at the end of the action when I want to close the image if I want to save the changes.
Knowing that this is the original I do not want it. I think the easiest way would be to add the size modification directly in the script?
1500px wide 72 dpi


try this

// save 1500px wide jpg;
// 2020, use it at your own risk;
if (app.documents.length > 0) {
var myDocument = app.activeDocument;
try {
var theName = myDocument.name.match(/(.*)\.[^\.]+$/)[1];
var thePath = myDocument.path;
}
catch (e) {
var theName = myDocument.name;
var thePath = "~/Desktop"
};
var thePrefix = "web";
// duplicate;
var myDocument = app.activeDocument.duplicate("theCopy", true);
myDocument.resizeImage(new UnitValue (1500, "px"), undefined, 72, ResampleMethod.AUTOMATIC);
// jpg options;
var jpgopts = new JPEGSaveOptions();
jpgopts.embedProfile = true;
jpgopts.formatOptions = FormatOptions.STANDARDBASELINE;
jpgopts.matte = MatteType.NONE;
jpgopts.quality = 10;
myDocument.saveAs((new File(thePath+"/"+thePrefix+"_"+theName+".jpg")),jpgopts,true);
// close;
myDocument.close(SaveOptions.DONOTSAVECHANGES)
};

1 Antwort

c.pfaffenbichler
Community Expert
Community Expert
September 17, 2020

A Script could handle the save-in-same-location-with-amended-name and the resizing, hhow omprtant is the droplet-aspect to you? (Though including a Script in an Action is possible anyway.)

Participating Frequently
September 17, 2020

Thank you for your reply.
The droplet is important because it will be used between 50 to 100 times a day by my entire team.
I am a newspaper iconographer and we need to provide 2 photos for each article. 1 file which will be converted into cmyk and 1 web file for the site.

I will look for the scripts, but it seems to me much more complicated than the actions ...

Thank you

c.pfaffenbichler
Community Expert
Community Expert
September 17, 2020

»I will look for the scripts, but it seems to me much more complicated than the actions«

True that, but what you get out of something often depends on what you put into it. 

Actions are easy to use but provide only limited options. 

Scripts are not that easy but they provide a lot more options. 

 

Please try this, it should create a jpg beside the original image with »web_« added at the start of the name (be aware: it would overwrite an existing jpg-file of the same name without prompting): 

// 2020, use it at your own risk;
if (app.documents.length > 0) {
var myDocument = app.activeDocument;
try {
var theName = myDocument.name.match(/(.*)\.[^\.]+$/)[1];
var thePath = myDocument.path;
}
catch (e) {
var theName = myDocument.name;
var thePath = "~/Desktop"
};
var thePrefix = "web_";
// jpg options;
var jpgopts = new JPEGSaveOptions();
jpgopts.embedProfile = true;
jpgopts.formatOptions = FormatOptions.STANDARDBASELINE;
jpgopts.matte = MatteType.NONE;
jpgopts.quality = 10;
myDocument.saveAs((new File(thePath+"/"+thePrefix+"_"+theName+".jpg")),jpgopts,true);
};