Hi guys,
I am wondering if anyone would know how to modify this script in order to create a new doc from a copied selection while retaining the transparent pixels? I am not even sure the clipboard would copy any pixels that has not data so maybe the approach would be different in this case.
So in other words I need to create a document that looks exactly the same as the selection including the transparent surrounding background. Obviously the doc needs to be the same size as the selection. As it now removes anything around the object.
function newDocFromClipboard() {
var desc = new ActionDescriptor();
var desc1 = new ActionDescriptor();
desc1.putString( stringIDToTypeID('preset'), "Clipboard" );
desc.putObject( charIDToTypeID('Nw '), charIDToTypeID('Dcmn'), desc1 );
executeAction( charIDToTypeID('Mk '), desc, DialogModes.NO );
};
newDocFromClipboard();
var myNewDoc = app.activeDocument;
if(myNewDoc.layers.length>1) myNewDoc.layers[1].remove();
By the way the code gives an error on this line saying that the function might not be available in my PS version.
executeAction( charIDToTypeID('Mk '), desc, DialogModes.NO );
I guess thats because it was taken by the listener in another PS version so it now works in a different way.
This is what my listener says when creating a new doc from selection.
// =======================================================
var idmodalStateChanged = stringIDToTypeID( “modalStateChanged” );
var desc1508 = new ActionDescriptor();
var idLvl = charIDToTypeID( "Lvl " );
desc1508.putInteger( idLvl, 1 );
var idStte = charIDToTypeID( “Stte” );
var idStte = charIDToTypeID( “Stte” );
var identer = stringIDToTypeID( “enter” );
desc1508.putEnumerated( idStte, idStte, identer );
executeAction( idmodalStateChanged, desc1508, DialogModes.NO );
// =======================================================
var idmodalStateChanged = stringIDToTypeID( “modalStateChanged” );
var desc1509 = new ActionDescriptor();
var idLvl = charIDToTypeID( "Lvl " );
desc1509.putInteger( idLvl, 0 );
var idStte = charIDToTypeID( “Stte” );
var idStte = charIDToTypeID( “Stte” );
var idexit = stringIDToTypeID( “exit” );
desc1509.putEnumerated( idStte, idStte, idexit );
executeAction( idmodalStateChanged, desc1509, DialogModes.NO );
// =======================================================