Skip to main content
Participant
June 28, 2018
Question

Issue with Batch processing and Actions

  • June 28, 2018
  • 2 replies
  • 1523 views

So I have a bunch of PSD files that I'm trying to resize and expand the background. The backgrounds are solid colors. The issue that I'm having is that the background layers are not named the same or the files don't have the same amount of layer.

When I go to expand the canvas size I want it to match the same color as the background. Here are my current actions list.

1. Image Size (reduced)

2. Merge Visible Layers

3. Canvas Size (Larger)

Here is where I get stuck. I want to fill the transparent canvas with the same color as the background but if I use the eye dropper tool it will do that one color. For example if one picture has a black background and I use that one to create my actions. When batch processing it will use the black color on the other files even if they have a blue background.

I need way to select the current color of the file that it's processing to fill the expanded canvas.

Any help would be greatly appreciated.

Thanks

This topic has been closed for replies.

2 replies

Bojan Živković11378569
Community Expert
Community Expert
June 29, 2018

This may be possible only if there is constant in your files like the top left pixels have a color which you want to use to expand canvas. If that's true then try to record step with Allow Tool Recording (check this option from Actions panel menu) to sample color from top left of your file. That will set that particular color as Foreground color. In the action you should have step: Use eyedropper. This step expanded wil show you Recording Data (data)....

What you need in your action (as I have quickly develop it) will be following steps:

  1. Ensure that image is flattened
  2. Use Eyedropper to set color from top left of the image
  3. Convert Background layer to normal so you can expand canvas with transparent pixels and to add layer below
  4. Use Canvas Size to expand canvas with transparent areas
  5. Create new blank layer below
  6. Fill with Foreground color (which will be set using eyedropper in the second step)
  7. Flatten image

Here is action which I have recorded. You can re-record Use eyedropper and Canvas Size steps (Canvas Size will expand canvas to 130% in my action) Eyedropper.atn - Google Drive

So test action and tell me how it works.

JJMack
Community Expert
Community Expert
June 29, 2018

I see no reason to flatten the document to destroy one's work.  However, to Automate all I had to add a little scripting the the action. I can not record tool useage Adobey Disables that feature on me,

ConvertBackground.jsx

// A Photoshop Script by JJMack's used by Photo Corners Action

// This script targets the bottom layer and makes sure it a normal layer.

// This script is supplied as is. It is provided as freeware.

// The author accepts no liability for any problems arising from its use.

/*

<javascriptresource>

<about>$$$/JavaScripts/ConvertBackground/About=JJMack's ConvertBackground.^r^rCopyright 2009 Mouseprints.^r^rScript utility for action.^rNOTE:Convert Background to normal layer if there is one!</about>

<category>JJMack's Action Utility</category>

</javascriptresource>

*/

// enable double-clicking from Mac Finder or Windows Explorer

#target photoshop // this command only works in Photoshop CS2 and higher

// bring application forward for double-click events

app.bringToFront();

// ensure at least one document open

if (!documents.length) {

   alert('There are no documents open.', 'No Document');

}

// if at least one document exists, then proceed

else {

   main();

}

///////////////////////////////////////////////////////////////////////////////

// main - main function

///////////////////////////////////////////////////////////////////////////////

function main() {

try {

// declare local variables

var layers = activeDocument.layers;

activeDocument.activeLayer = layers[layers.length-1]; // Target Bottom Layer

activeDocument.activeLayer.isBackgroundLayer=0; // Make it a normal Layer

}

// display error message if something goes wrong

catch(e) { alert(e + ': on line ' + e.line, 'Script Error', true); }

}

SetSamplerColor

var orig_ruler_units = app.preferences.rulerUnits; 

app.preferences.rulerUnits = Units.PIXELS; // Set the ruler units to PIXELS 

for (var s=0,len=app.activeDocument.colorSamplers.length;s<len;s++) { 

var colorSamplerRef = app.activeDocument.colorSamplers

app.foregroundColor=colorSamplerRef.color;

}  

app.preferences.rulerUnits = orig_ruler_units; // Reset units to original settings 

JJMack
Bojan Živković11378569
Community Expert
Community Expert
June 29, 2018

It is optional step to flatten image because I believe that's what this guy wants. He has mentioned that in the initial post. With Sample All Layers in Options bar for Eyedropper when playing action everything still works fine but action will be more complex because the document may have or have not Background layer.

JJMack
Community Expert
Community Expert
June 29, 2018

It sounds like your PSD do not have a background layer. If you did when you expand the canvas size the background layer expanded canvas would be filled with the background color for it does not support transparency. If you expand a document canvas that does not have a background layer no pixels will be added the expanded canvas area will be transparent. No Layers pixels are changed layer sizes do not change. Your Action would need to use the eye dropper tool to set the  background or foreground color swatch.  Expand the canvas to the size you want. Add a new empty layer on top and fill that layer with the background color. Move the layer to the bottom of the stack and covert it to a background layer if you want.

JJMack