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

save as with active layer or TOP layer name in photoshop

Explorer ,
Apr 21, 2017 Apr 21, 2017

Copy link to clipboard

Copied

I am wondering if any one can help me, I have an action that need to save jpg as active or top layer name, below is the code that i have using for change name from file name to layer name so now i want to save file as active layer name....

I have tried every thing but not get any clues please help if you can?

var idoc = app.activeDocument;

idoc.activeLayer.name = idoc.name.slice(0, idoc.name.lastIndexOf ("."));

TOPICS
Actions and scripting

Views

5.7K

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 , Apr 21, 2017 Apr 21, 2017

There is a slight mistake in his script try this. I just change path to docpath "path" must be a reserved name or there is an error in Adobe scripting plug-in.

var doc = app.activeDocument;

var docpath = doc.path;

var activeLayer = doc.activeLayer;

var saveFile = File(docpath + "/" + activeLayer.name + ".jpg");

  saveJPG(saveFile, 10)

function saveJPG(saveFile, jpegQuality) {

  var jpgSaveOptions = new JPEGSaveOptions();

  jpgSaveOptions.embedColorProfile = true;

  jpgSaveOptions.formatOptions = FormatOp

...

Votes

Translate

Translate
Adobe
Advocate ,
Apr 21, 2017 Apr 21, 2017

Copy link to clipboard

Copied

There you go. It saves as JPEG image.

var doc = app.activeDocument;

var path = doc.path;

var activeLayer = doc.activeLayer;

var saveFile = File(path + "/" + activeLayer.name + ".jpg");

  saveJPG(saveFile, 10)

function saveJPG(saveFile, jpegQuality) {

  var jpgSaveOptions = new JPEGSaveOptions();

  jpgSaveOptions.embedColorProfile = true;

  jpgSaveOptions.formatOptions = FormatOptions.STANDARDBASELINE;

  jpgSaveOptions.matte = MatteType.NONE;

  jpgSaveOptions.quality = jpegQuality;

  activeDocument.saveAs(saveFile, jpgSaveOptions, true, Extension.LOWERCASE);

};

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
Explorer ,
Apr 21, 2017 Apr 21, 2017

Copy link to clipboard

Copied

Thank you so much "Tomas" for your quick help, I have run this script but not thing happen when run this script,  I have no idea where is the file is saved?

I just want to save document with active layer's name only not final file or final result, because there many other layers etc i just want to save file with the name of top layer... I have attaching my .psd file for review.

Actually I want to replace 3d screen image with new images, so i have smart object to change image but there is no way to save 3d screen with new inserted image, currently I'm using this script to change document name by layer name and then duplicate layer to main document and then hide duplicated layer so this hidden layer having actual name which i wan to save final document...

current script to change layer name with document.

  1. var idoc = app.activeDocument; 
  2. idoc.activeLayer.name = idoc.name.slice(0, idoc.name.lastIndexOf ("."));

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
Advocate ,
Apr 21, 2017 Apr 21, 2017

Copy link to clipboard

Copied

File is being saved to same location where your original PSD file is. And it does exactly what you asked in your first request - save jpg as active or top layer name

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
Explorer ,
Apr 21, 2017 Apr 21, 2017

Copy link to clipboard

Copied

I'm really sorry, I have checked but the source folder of PSD file is blank and file not saving, I'm sure i am doing some thing wrong....

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
Contributor ,
Apr 21, 2017 Apr 21, 2017

Copy link to clipboard

Copied

Tomas does not save me to the original folder

But I saw that it saves the file in the photoshop installation folder

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 ,
Apr 21, 2017 Apr 21, 2017

Copy link to clipboard

Copied

There is a slight mistake in his script try this. I just change path to docpath "path" must be a reserved name or there is an error in Adobe scripting plug-in.

var doc = app.activeDocument;

var docpath = doc.path;

var activeLayer = doc.activeLayer;

var saveFile = File(docpath + "/" + activeLayer.name + ".jpg");

  saveJPG(saveFile, 10)

function saveJPG(saveFile, jpegQuality) {

  var jpgSaveOptions = new JPEGSaveOptions();

  jpgSaveOptions.embedColorProfile = true;

  jpgSaveOptions.formatOptions = FormatOptions.STANDARDBASELINE;

  jpgSaveOptions.matte = MatteType.NONE;

  jpgSaveOptions.quality = jpegQuality;

  activeDocument.saveAs(saveFile, jpgSaveOptions, true, Extension.LOWERCASE);

};

JJMack

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
Explorer ,
Apr 21, 2017 Apr 21, 2017

Copy link to clipboard

Copied

Thank you so much JJMack​you save my day! Yes that is some thing that exactly i needed. Thank you for your great help...

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
Explorer ,
Apr 22, 2017 Apr 22, 2017

Copy link to clipboard

Copied

Thanks Mack for your script... script works correctly, I just having one issue, file will saving just one fiile which i have put when create action means if i run second time action will not change file name...

Here is my steps, first i change smart object open new image ctrl + A, copy image and past to smart object and rename layer of new image's by this script :

  1. var idoc = app.activeDocument;
  2. idoc.activeLayer.name = idoc.name.slice(0, idoc.name.lastIndexOf ("."));

and duplicate this new named layer to main mock up so this layer show at top of layer panel and click eye button of layer to hide this layer content and finally save this file via your above script and last step to delete this duplicate layer and stop action...

But problem is file will saving for first named layer and not changing when run second time?

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 ,
Apr 22, 2017 Apr 22, 2017

Copy link to clipboard

Copied

Replacing the contents of a smart object layer. Its object requires a replacement objects the is the sames size ad the original object. For there is an associated transform for the smart object which doe not get replaced. Also the Smart Object Layer name is not replaced. You would need to change the layer name when you replace its content.  If you want to automate the process scripting it would be your best option.  Scripts can use logic to get at file names  and layer names and use them in their processing.  If you want only to record and edit action you should look into Scripts that you can add you actions to like the Image processor and Image Processor Pro scripts.  These can process your image files and save output image files you want that are the file type yow want with the names you want and fitted to any size you want.  The Scripts do all the hard part.  You can add actions to add your customization.

You would not however be able to process a Template psd file you populate with replacement images into a template smart object layer.  You would need to Script the whole process.  Something like my Batch populating scripts but with some template design that employs smart object layers designed the have their contents replaced soy the images will be transformed like the original object.

My scripts do not do that. My Template design is very simple they just contain Alpha channels named Image 1, Image 2, ...; Image N that map the location size and shape of where image should be populated.   Image Files are just placed in as smart object layers sized positions and mask to shape using the Alpha channels maps.  The smart object layer transform are simply a straight size and position transform no distortion like rotation and perspective is supported.  That can be done later manually if needed by editing the populated layered template and changing the transforms the script created.

JJMack

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 ,
Jun 13, 2019 Jun 13, 2019

Copy link to clipboard

Copied

JJMack​ I wonder if you could help solve a scripting/action question similar to the one on this thread. I have been using Generate Assets but can't rely on the color quality in output files.

I set up an action exporting groups (they are closed) one at a time with Save for Web Legacy which preserves the colors and uses the settings I want BUT the saved files are saved with the name of the source file instead of the group name. I tried toggling Dialog in the actions so I can write the name of each file but I know there has to be a more elegant way to do this after reading your answer.

I am looking for a script to replicate what Generate Assets does for selected groups or layers BUT using an action or a saved Save for Web Legacy settings. The goal is to automate the save for web Legacy using the Group Name of the top layer, close the layer and select the layer below, then start over.

-C

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 ,
Jun 13, 2019 Jun 13, 2019

Copy link to clipboard

Copied

I don't enable the Generate Plug-in.  I do not know how generate works.  Actions can not use logic to create output file names, scripts can.  If you do not know how to program a Photoshop script.  You may be able to use a script like Image Processor or Image Processor Pro to save your output files that  are created by your actions. Action create. you cans include actions in the processing of your image files. Image Processor Pro has more options.  However, I feel you will most likely need a custom script.

JJMack

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 ,
Jun 14, 2019 Jun 14, 2019

Copy link to clipboard

Copied

Thank you JJMack​. This is very helpful. Would you happen to know where I can find someone who writes PSD Scripts?

-C

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 ,
Jun 14, 2019 Jun 14, 2019

Copy link to clipboard

Copied

If you have scripting question ask them in the forum. To write a Photoshop you need to know how Photoshop works well and you need to be  able to program using JavaScript.  Scripts are programs you need to have programming skills.

JJMack

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 ,
Jun 14, 2019 Jun 14, 2019

Copy link to clipboard

Copied

LATEST

File menu > Export > Layers to files

Or you could try the Layer Saver or Layer Saver Plus scripts from Paul Riggott:

GitHub - Paul-Riggott/PS-Scripts: Photoshop Scripts

Or perhaps try some scripts mentioned here:

Re: Quick Export as PNG as standalone script

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 ,
Apr 21, 2017 Apr 21, 2017

Copy link to clipboard

Copied

Actually I want to replace 3d screen image with new images, so i have smart object to change image but there is no way to save 3d screen with new inserted image, currently I'm using this script to change document name by layer name and then duplicate layer to main document and then hide duplicated layer so this hidden layer having actual name which i wan to save final document...

That sound like you want to replace an image that is part of a composite or image document. Replace a layer.  Have you look at Photoshop's data-driven graphics feature or looked for a script that will batch populate a Photoshop PSD template file.

Also when replacing the contents of a smart object layer the replacement object file needs to be the same size as the original file so the smart object layer associated transform will work correctly. So I do not think data-driven graphics variable can be a smart object layer.  I also do not know of any Photoshop script that has been made public the batch replaces smart object layers contents.  If you do not need the images to be transformed like rotate and perspective you would be more likely find a script the can replace pixel image layers or place in image smart object layers  that are sized and masked to shaped.

For example the batch scripts in my Photoshop Photo Collage toolkit.

Photo Collage Toolkit

Photoshop scripting is powerful and I believe this package demonstrates this

The package includes four simple rules to follow when making Photo Collage Template PSD files so they will be compatible with my Photoshop scripts.

  1. Size the photo collage templates for the print size you want - width, height and print DPI resolution.
  2. Photo collage templates must have a Photoshop background layer. The contents of this layer can be anything.
  3. Photo collage templates must have alpha channels named "Image 1", "Image 2", ... "Image n".
  4. Photo collage templates layers above the background layers must provide transparent areas to let the images that will be placed below them show through.

There are fifteen scripts in this package they provide the following functions:

  1. HelpPhotoCollageToolkit.jsx - Online Help
  2. TestCollageTemplate.jsx - Used to test a Photo Collage Template while you are making it with Photoshop.
  3. CollageTemplateBuilder.jsx - Can build Templates compatible with this toolkit's scripts.
  4. LayerToAlphaChan.jsx - Used to convert a Prototype Image Layer stack into a template document.
  5. InteractivePopulateCollage.jsx - Used to interactively populate Any Photo Collage template. Offers most user control inserting pictures and text.
  6. ReplaceCollageImage.jsx - use to replace a populated collage image Smart Object layer with an other image correctly resized and positioned.
  7. ChangeTextSize.jsx - This script can be used to change Image stamps text size when the size used by the populating did not work well.
  8. PopulateCollageTemplate.jsx - Used to Automatically populate a Photo Collage template and leave the populated copy open in Photoshop.
  9. BatchOneImageCollage.jsx - Used to Automatically Batch Populate Collage templates that only have one image inserted. The Collage or Image may be stamped with text.
  10. BatchMultiImageCollage.jsx - Used to Automatically Batch Populate Any Photo Collage template with images in a source image folder. Easier to use than the interactive script. Saved collages can be tweaked.
  11. PasteImageRoll.jsx - Paste Images into a document to be print on roll paper.
  12. BatchPicturePackage.jsx - Used to Automatically Batch Populate Any Photo Collage template with an image in a source image folder.  Images Rotates for best fit.
  13. BatchPicturePackageNoRotate.jsx - Used to Automatically Batch Populate Any Photo Collage template with an image in a source image folder.
  14. PopulatePicturePackage.jsx - Used to Automatically populate a Photo Collage template Fill with the same single image and leave the populated copy open in Photoshop.
  15. PCTpreferences.jsx - Edit This File to Customize Collage Populating scripts default setting and add your own Layer styles.

Documentation and Examples

JJMack

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