Quantcast
Channel: Adobe Community: Message List - Photoshop Scripting
Viewing all articles
Browse latest Browse all 27456

Re: canvas size with backgroundcolor

$
0
0

I believe added canvas will only be filled with pixels if the document has a background layer because the background layer does not support transparency where all other layer do.  Only the background layer will have pixels in the added canvas. All other layer will remain the same size they were abd contain their current content. Only it position over the new canvas is adjusted.   If your image has a background layer try setting Photoshop's background color to the color you want the added canvas to have before you re-size the documents canvas.

 

You could also create a function you the would use the action manager to be able to add canvas like Photoshop's  Canvas size dialog where you can set anchor point canvas color width and eight  the units to use and wither it relative to the current canvas size or not.  Use the scriptlistener plugin to record various forms of Photoshop's Image Canvas Size dialog and modify the code to create a function like if for your script.

 

// =======================================================

var idCnvS = charIDToTypeID( "CnvS" );                                                       <----- Canvas Size

    var desc3 = new ActionDescriptor();

    var idRltv = charIDToTypeID( "Rltv" );                                                         <--------------------relative

    desc3.putBoolean( idRltv, true );                                                                 <--- true false

    var idWdth = charIDToTypeID( "Wdth" );                                                     <--- width

    var idPxl = charIDToTypeID( "#Pxl" );                                                           <--- units

    desc3.putUnitDouble( idWdth, idPxl, 300.000000 );                                      <---- size

    var idHght = charIDToTypeID( "Hght" );                                                        <---- height

    var idPxl = charIDToTypeID( "#Pxl" );                                                           <---- units

    desc3.putUnitDouble( idHght, idPxl, 200.000000 );                                        <-----size

    var idHrzn = charIDToTypeID( "Hrzn" );

    var idHrzL = charIDToTypeID( "HrzL" );

    var idCntr = charIDToTypeID( "Cntr" );

    desc3.putEnumerated( idHrzn, idHrzL, idCntr );                                              <------------------ Anchor point

    var idVrtc = charIDToTypeID( "Vrtc" );

    var idVrtL = charIDToTypeID( "VrtL" );

    var idTop = charIDToTypeID( "Top " );

    desc3.putEnumerated( idVrtc, idVrtL, idTop );

    var idcanvasExtensionColorType = stringIDToTypeID( "canvasExtensionColorType" ); <----- canvas  color

    var idcanvasExtensionColorType = stringIDToTypeID( "canvasExtensionColorType" );

    var idGry = charIDToTypeID( "Gry " );

    desc3.putEnumerated( idcanvasExtensionColorType, idcanvasExtensionColorType, idGry );

executeAction( idCnvS, desc3, DialogModes.NO );


Viewing all articles
Browse latest Browse all 27456

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>