How to resize an image layer to the same size as the width of the document respecting its aspect ratio.


how resize image layer same size width of document respecting aspect ratio.

untitled-2.jpg

#target photoshop; if(documents.length){ var doc = app.activedocument; var layer = doc.activelayer; var per = doc.width.value/(layer.bounds[2]-layer.bounds[0])*100; layer.resize(per,per); doc.selection.selectall(); align('adch'); align('adcv' ); doc.selection.deselect(); } 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 );  };  


More discussions in Photoshop Scripting


adobe

Comments

Popular posts from this blog

Reader DC

AdobeIDの作り方

Adobe InDesign CC 2017 has stopped working