What's new
Photoshop Gurus Forum

Welcome to Photoshop Gurus forum. Register a free account today to become a member! It's completely free. Once signed in, you'll enjoy an ad-free experience and be able to participate on this site by adding your own topics and posts, as well as connect with other members through your own private inbox!

Batch Automation Batch automation problem


Big Arted

New Member
Messages
2
Likes
0
Hi, I am trying to create an action that will import one image 1 (a photo) into another image 2 (a picture of a room) and place image 1 on the wall of the room like a wall picture. I need to do this for a lot of different '1' images so have tried making an action. I can do all this manually while recording the action but when I come to use it in batch process or script process the 'transform' part of image 1 which is making it smaller stalls the action with a 'Transform' is unavailable message. Anyone got any ideas....the final images are to show 'box canvas prints' on a wall above a sofa to show on a website.
Thanks in advance
 
All is not lost, it just means you need to set up the following script.

What you need to do is create a new action that does :-

File - Place - select the picture you want placed, hit return to accept the defaul position.
(This will be in the center)
From the action palette fly out menu select "Insert Menu Item" then File - Scripts - select the script.

Code:
main();
function main(){
if(!documents.length) return;
if (activeDocument.activeLayer.kind != LayerKind.SMARTOBJECT) return;
/////////////////////////////// Amend to suit /////////////////////////////////
var Percent = 25; /* Resize logo to percentage of smallest side of doc */
var OffsetX = 0; /* Move logo pixels to the right - left */
var OffsetY = 20; /* Move  logo pixels up - down. */
var Opacity = 100; /* Opacity of logo */
/////////////////////////////////////////////////////////////////////////////////////////////
var startRulerUnits = app.preferences.rulerUnits;
app.preferences.rulerUnits = Units.PIXELS;
var myDoc = activeDocument;
rasterLayer();
var LB = myDoc.activeLayer.bounds; 
var docHeight = myDoc.height;
var docWidth = myDoc.width;
var LHeight = Math.abs(LB[3].value) - Math.abs(LB[1].value);
var LWidth = Math.abs(LB[2].value) - Math.abs(LB[0].value);    
var percentageHeight = ((docHeight/LWidth)*Percent); 
var percentageWidth = ((docWidth/LWidth)*Percent);
if(docWidth < docHeight){
myDoc.activeLayer.resize(percentageWidth,percentageWidth,AnchorPosition.MIDDLECENTER);
}else{   
  myDoc.activeLayer.resize(percentageHeight,percentageHeight,AnchorPosition.MIDDLECENTER);
  }
activeDocument.selection.selectAll();
   // align methods
   // 'AdCH' - center horizontal 
   // 'AdCV' - center vertical 
   // 'AdLf' - left 
   //  'AdRg' - Right
   // 'AdBt' - bottom 
   //  'AdTp' - Top
align('AdCH');
align('AdTp');
activeDocument.selection.deselect();
activeDocument.activeLayer.translate(OffsetX,OffsetY);
activeDocument.activeLayer.opacity=Opacity;
app.preferences.rulerUnits = startRulerUnits;
}
function align(method){ 
   var desc = new ActionDescriptor();
           var ref = new ActionReference();
           ref.putEnumerated( charIDToTypeID( "Lyr " ), charIDToTypeID( "Ordn" ), charIDToTypeID( "Trgt" ) ); 
       desc.putReference( charIDToTypeID( "null" ), ref ); 
       desc.putEnumerated( charIDToTypeID( "Usng" ), charIDToTypeID( "ADSt" ), charIDToTypeID( method ) );
   executeAction( charIDToTypeID( "Algn" ), desc, DialogModes.NO ); 
};
function rasterLayer() {
    var desc9 = new ActionDescriptor();
        var ref4 = new ActionReference();
        ref4.putEnumerated( charIDToTypeID('Lyr '), charIDToTypeID('Ordn'), charIDToTypeID('Trgt') );
    desc9.putReference( charIDToTypeID('null'), ref4 );
    executeAction( stringIDToTypeID('rasterizeLayer'), desc9, DialogModes.NO );
};

Copy and paste the code into ExtendScript Toolkit.
This utility can be found:-
PC: C:\Program Files\Adobe\Adobe Utilities
MAC: <hard drive>/Applications/Utilities/Adobe Utilities
Save the script to the following folder:-
PC: C:\Program Files\Adobe\Adobe Photoshop CS2\Presets\Scripts

MAC: <hard drive>/Applications/Adobe Photoshop CS2/Presets/Scripts
N.B. if your are using Vista or Windows 7 you will need to save the script elsewhere and then copy it to the relevant folder, this is due to permissions.
If Photoshop was open close and restart it so that it can pick up the new script.

You will need to amend the script so that the log/picture is the correct size and positioned as you wish.

Hope this helps.
 


Write your reply...

Back
Top