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

Add an Image Layer

Guest
May 07, 2009 May 07, 2009

Copy link to clipboard

Copied

I just want to add a layer to an image in Photoshop CS3, how is it possbile to add an image layer to the active document(image)

TOPICS
Actions and scripting

Views

2.4K

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
Adobe
Advisor ,
May 07, 2009 May 07, 2009

Copy link to clipboard

Copied

Open the document.

Select all

Copy

Close the document

Paste into the existing document.

Usually, things are a bit more complicated than that, but that's the basic flow.

You could also use Place the image as a smart object, etc...

-X

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
Guest
May 08, 2009 May 08, 2009

Copy link to clipboard

Copied

That is what I am doing manually...Is it possible that we can do all these steps programatically. I tried doing that with no success

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
Valorous Hero ,
May 08, 2009 May 08, 2009

Copy link to clipboard

Copied

Here is the basics...

if(documents.length){
var selectedFile =null;
while(selectedFile == null){
selectedFile = File.openDialog("Please select file.","File:*.*");
}
open(selectedFile);
activeDocument.flatten();
activeDocument.selection.selectAll();
activeDocument.selection.copy();
app.activeDocument.close(SaveOptions.DONOTSAVECHANGES);
activeDocument.paste();
}

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
Guide ,
May 08, 2009 May 08, 2009

Copy link to clipboard

Copied

I don't have CS3 only CS2 (so I use a script listener function instead) but can't this be done using

app.open(someFile, asSmartObject)

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
Valorous Hero ,
May 08, 2009 May 08, 2009

Copy link to clipboard

Copied

That would just open a new document as a smart object Mark, if you wanded to add a smart object as a layer this should do it..

if(documents.length){
var selectedFile =null;
while(selectedFile == null){
selectedFile = File.openDialog("Please select file.","File:*.*");
}
placeFile(selectedFile);
}
function placeFile(file) {
  function cTID(s) { return app.charIDToTypeID(s); };
  function sTID(s) { return app.stringIDToTypeID(s); };
    var desc124 = new ActionDescriptor();
    desc124.putPath( cTID('null'), new File( file ) );
    desc124.putEnumerated( cTID('FTcs'), cTID('QCSt'), cTID('Qcsa') );
        var desc125 = new ActionDescriptor();
        desc125.putUnitDouble( cTID('Hrzn'), cTID('#Pxl'), 0.000000 );
        desc125.putUnitDouble( cTID('Vrtc'), cTID('#Pxl'), 0.000000 );
    desc124.putObject( cTID('Ofst'), cTID('Ofst'), desc125 );
    desc124.putBoolean( cTID('AntA'), true );
    executeAction( cTID('Plc '), desc124, DialogModes.NO );
};

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
Advisor ,
May 08, 2009 May 08, 2009

Copy link to clipboard

Copied

This function places an image as a smart image into the active document. The resize() calll in there works around a problem if the ppis are not the same.

After this you'll probably want to resize, translate, and rasterize the layer.

-X

function placeImage(file) {

    cTID = function(s) { return app.charIDToTypeID(s); };
    sTID = function(s) { return app.stringIDToTypeID(s); };

    var desc = new ActionDescriptor();
    desc.putPath( cTID('null'), file);
    desc.putEnumerated( cTID('FTcs'), cTID('QCSt'), cTID('Qcsa') );
        var ldesc = new ActionDescriptor();
        ldesc.putUnitDouble( cTID('Hrzn'), cTID('#Pxl'), 0.000000 );
        ldesc.putUnitDouble( cTID('Vrtc'), cTID('#Pxl'), 0.000000 );
    desc.putObject( cTID('Ofst'), cTID('Ofst'), ldesc );
    executeAction( cTID('Plc '), desc, DialogModes.NO );

    var layer = app.activeDocument.activeLayer;

    layer.resize(100, 100);

    return layer;
  }

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
Guide ,
May 08, 2009 May 08, 2009

Copy link to clipboard

Copied

LATEST

Thanks, both of you I was only going off what I read in the scripting guide? I already use the same cleaned up script listener code as what you have for placing an image I presumed wrongly that this method could be used if a file was already open to open another and place it. At least I will know thats not the case when I get to upgrade. The layer resize tip is cool. I also have script listener function to rasterize a layer.

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