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

Droplet with prefix in original folder

Community Beginner ,
Sep 17, 2020 Sep 17, 2020

Copy link to clipboard

Copied

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

TOPICS
Actions and scripting

Views

769

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 , Sep 17, 2020 Sep 17, 2020

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);
//
...

Votes

Translate

Translate
Adobe
Community Expert ,
Sep 17, 2020 Sep 17, 2020

Copy link to clipboard

Copied

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.)

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
Community Beginner ,
Sep 17, 2020 Sep 17, 2020

Copy link to clipboard

Copied

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

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
Community Expert ,
Sep 17, 2020 Sep 17, 2020

Copy link to clipboard

Copied

»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);
};

 

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
Community Beginner ,
Sep 17, 2020 Sep 17, 2020

Copy link to clipboard

Copied

WOW, thank you so much !!
I managed to get it to work, however is it possible to integrate a size constraint with 1500px wide and 72 dpi?
How do you use it as easily as possible? Droplet?

Thank you so much !!!!

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
Community Expert ,
Sep 17, 2020 Sep 17, 2020

Copy link to clipboard

Copied

The scaling could be included in the Script but the question is how far you want to go into Scripting. 

 

As it is the Script in an Action that first uses File > Automate > Fit Image should work fine in a Droplet. 

You would need to »install« the Script on all your colleagues’ computers, too, naturally if they use the droplet.  

 

But if you want to compund the whole process (including separating and saving the second, CMYK image) into one script it might also be useful to apply a Keyboard Shortcut to the Script and trigger it that way. 

But it depends on how you are likely to use it – one image at a time or a bunch of images at a time (especially if they are not open yet the droplet might still seem advantageous)? 

 

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
Community Beginner ,
Sep 17, 2020 Sep 17, 2020

Copy link to clipboard

Copied

The ideal would be to be able to drag & drop the photo on the droplet and have it done automatically, with the photo closed at the end.
The goal for me being that it is the simplest and the most transparent for my team.

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
Community Expert ,
Sep 17, 2020 Sep 17, 2020

Copy link to clipboard

Copied

It’s perfectly fine to use small scripts within larger Actions (to handle the saving/naming) to begin with.

The Scripts need to be installed to run those as Droplets if I remember correctly, so like I mentioned you would need to make sure all teammembers have Droplet and Script/s. 

 

If you want to pursue Scripting further you could do the whole process (scaling, separating, dabing, …) via Script but to be able to use a Droplet you would still need to include the Script in an Action. 

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
Community Beginner ,
Sep 17, 2020 Sep 17, 2020

Copy link to clipboard

Copied

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

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
Community Expert ,
Sep 17, 2020 Sep 17, 2020

Copy link to clipboard

Copied

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)
};

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
Community Beginner ,
Sep 17, 2020 Sep 17, 2020

Copy link to clipboard

Copied

Thank you, thank you, thank you, 1000 thank you !!!
It works great !!

Very nice job 😉

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
Community Beginner ,
Sep 17, 2020 Sep 17, 2020

Copy link to clipboard

Copied

I'm abusing but do you know if it is possible via the script to minimize photoshop after the execution of the action?

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
Community Expert ,
Sep 18, 2020 Sep 18, 2020

Copy link to clipboard

Copied

I think neither Photoshop’s DOM-code nor its AM-code provide for that option. 

It might be possible to simulate the corresponding keystroke event (cmd-H) but I am not sure how exactly. 

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
Community Beginner ,
Sep 18, 2020 Sep 18, 2020

Copy link to clipboard

Copied

Thank you for this additional info.
Have a very good day

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
Community Expert ,
Sep 18, 2020 Sep 18, 2020

Copy link to clipboard

Copied

If you want to pursue Scripting further feel free to start new threads on particular issues, there are other Forum regulars who know the matter better than me. 

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
Community Expert ,
Sep 18, 2020 Sep 18, 2020

Copy link to clipboard

Copied

Are you and your colleagues on Macs or Windows? 

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
Community Expert ,
Sep 18, 2020 Sep 18, 2020

Copy link to clipboard

Copied

On Mac adding this line should work: 

var sh = app.system("osascript -e 'tell application \"System Events\" to keystroke keystroke \"h\" using \{command down, control down\}'");

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
Community Beginner ,
Sep 21, 2020 Sep 21, 2020

Copy link to clipboard

Copied

Hello,

Thank you for this additional info.
All of my service is on Windows.
Besides, they thank you all for the time saved thanks to this script 😉

However, I come back with a question on resizing.
Is it possible to put 1500px in max size and not in recut.
If my original is 2000px then it resizes to 1500px if on the other hand it is 800px less then it leaves it like this?

Thank you

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
Community Expert ,
Sep 21, 2020 Sep 21, 2020

Copy link to clipboard

Copied

Try this: 

// save 1500px wide jpg;
// 2020, use it at your own risk;
if (app.documents.length > 0) {
var originalRulerUnits = app.preferences.rulerUnits;
app.preferences.rulerUnits = Units.PIXELS;
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);
if (myDocument.width > 1500) {
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);
// reset;
app.preferences.rulerUnits = originalRulerUnits;
};

 

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
Community Beginner ,
Sep 22, 2020 Sep 22, 2020

Copy link to clipboard

Copied

Hello,

The needs are refined with the use of the script.

My editorial system does not support .png ...

If I recover a .png image, is it possible in the script to force the web_image.png file to be saved as .jpg?

And even would it be possible to save a copy of the original in .jpg transparently in the original folder without a "copy" at the end of the name?
What would when the process was over

image.png
image.jpg
web_image.jpg

thank you so much

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
Community Expert ,
Sep 22, 2020 Sep 22, 2020

Copy link to clipboard

Copied

jpgs have no transparency. 

 

I think it is time that you dig into Scripting yourself. 

// save as jpg if png;
// 2020, use it at your own risk;
if (app.documents.length > 0) {
var originalRulerUnits = app.preferences.rulerUnits;
app.preferences.rulerUnits = Units.PIXELS;
var myDocument = app.activeDocument;
try {
var theName = myDocument.name.match(/(.*)\.[^\.]+$/)[1];
var theSuffix = myDocument.name.match(/.\D{3}$/i);
var thePath = myDocument.path;
}
catch (e) {
var theName = myDocument.name;
var thePath = "~/Desktop"
};
// jpg options;
var jpgopts = new JPEGSaveOptions();
jpgopts.embedProfile = true;
jpgopts.formatOptions = FormatOptions.STANDARDBASELINE;
jpgopts.matte = MatteType.NONE;
jpgopts.quality = 12;
// if png save as jpg;
if (theSuffix == ".png") {
myDocument.flatten();
myDocument.saveAs((new File(thePath+"/"+theName+".jpg")),jpgopts,false);
};
};

 

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
Community Beginner ,
Sep 25, 2020 Sep 25, 2020

Copy link to clipboard

Copied

Hello,

Thank you very much, it works perfectly.
Indeed I would have to get started ....

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
Community Expert ,
Sep 25, 2020 Sep 25, 2020

Copy link to clipboard

Copied

LATEST

There are helpful regulars on the Forum whose Scripting-knowledge exceeds mine, so in case you pursue Photoshop Scripting and questions turn up feel free to start new threads accordingly (after doing a Forum search first, though). 

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
Community Beginner ,
Sep 21, 2020 Sep 21, 2020

Copy link to clipboard

Copied

Great thanks a lot !!!

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