Resize width of layer to canvas width

I'm having some trouble resizing a layer width to canvas width.
I know one way that works and it involves creating new document, resizing, then pasting back in. This seems extranious it seems there should be an easier way.
    var width = doc.width;
    var bounds = layer.bounds;
    var height = bounds[3]-bounds[1]; \\get height because I want this the same
    var width = doc.width;
    layer.resize (width, height, AnchorPosition.MIDDLECENTER);
this seems to fail even though it seems the documentation says it should work? maybe I am misunderstanding.

When dealing with layers the resize is done with percentage, so your
layer width and height are allways 100% To make it fit the document you need to work out the ratio and then resize.
This should do what you want....
main();
function main(){
    if(!documents.length) return;   
    if (activeDocument.activeLayer.isBackgroundLayer) return;
    fitLayerToDoc();
function fitLayerToDoc(){  
var strtRulerUnits = app.preferences.rulerUnits;
var strtTypeUnits = app.preferences.typeUnits;
app.preferences.rulerUnits = Units.PIXELS;
app.preferences.typeUnits = TypeUnits.PIXELS;           
var docWidth = activeDocument.width.value;
var LB = activeDocument.activeLayer.bounds;              
var LWidth = LB[2].value - LB[0].value;               
var percentageWidth = ((docWidth/LWidth)*100);
activeDocument.activeLayer.resize(percentageWidth,100,AnchorPosition.MIDDLECENTER);
align( 'AdRg');
app.preferences.rulerUnits = strtRulerUnits;
app.preferences.typeUnits = strtTypeUnits;
function align(method) {
activeDocument.selection.selectAll();
   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 ) );
    try{
   executeAction( charIDToTypeID( "Algn" ), desc, DialogModes.NO );
   }catch(e){}
   activeDocument.selection.deselect();

Similar Messages

  • Auto resize width height in TextFlow controller

    HI,
    We are facing the problem in auto resize width height in TextFlow controller. Content is overlaping withing the controller or sometimes it's seems like not full containt displaying on the control.
    We are writing the below code in the flashx.textLayout.events.CompositionCompleteEvent listiner to orgnize the above step:
         var controller:ContainerController = new ContainerController();
         textFlow.flowComposer.composeToPosition();
         var contentBounds:Rectangle = _controller.getContentBounds();
       _controller.setCompositionSize(_controller.compositionWidth, contentBounds.height);
       textFlow.flowComposer.addController(_controller);
       textFlow.flowComposer.updateAllControllers();
    Please correct if are missing any steps above.
    Regards,
    R.BS

    Hi,
    I have got the solution on my last query. Below is the code to get rid of the content display and auto adjust the width & height of the controller:
    var textHeight:int = Math.ceil(_controller.getContentBounds().height);
       if (textHeight > _controller.compositionHeight) {
         TextDataHeight = textHeight + 12;
                   _controller.setCompositionSize(TextDataWidth ,TextDataHeight);
                   textFlow.flowComposer.updateAllControllers();
    I have also set the TextDataHeight = 50 to display complete paragraph text.
    Due to this I have one problem arise that is indentation of the paragraph content or bulleted text on my content.
    Is any one have the solution on this?
    Looking forward for your response.
    Regards,
    R.BS

  • How and where do I resize footage? In the Canvas or Viewer

    I shot some footage and there needs to be some resizing...when and where do I do that ...am I looking to work in the canvass, and what makes the resize "permanent"
    Thanks
    Don

    Set the Canvas window to Image+Wireframe mode. Use the wireframe to scale the image any size you want.
    You also do the same thing by loading the clip into the Viewer window and using the Scale control.
    -DH

  • Resizing a selected layer

    Hi...I'm trying to resize a selected layer however when I select the layer I see no guidelines, no corner points for resizing. I'm sure it's a setting somewhere. Can anyone help?

    Do you have Auto-Select and Show-Transform Controls enabled?
    Nancy O.

  • Resize Width of the frame in BrowserBasedHelp

    Hi for All,
    How can I do to resize the "width" of the frame as described in the example picture? The frame I want to increase the size is represented with a number (1) in the image.
    Regards,
    Christian

    Hi there
    Jeff gave you the information for WebHelp or FlashHelp and both of those are "browser based". Am I correct in assuming from your response that you are using the "Browser Based" version of AIR Help?
    If that's the case, I'm not sure I've ever seen anyone document how to modify that.
    Cheers... Rick
    Helpful and Handy Links
    RoboHelp Wish Form/Bug Reporting Form
    Begin learning RoboHelp HTML 7 or 8 moments from now - $24.95!
    Adobe Certified RoboHelp HTML Training
    SorcererStone Blog
    RoboHelp eBooks

  • How to keep scale for height when resizing width?

    Hi i have a serious of images different sizes/ ratios, which need to display at a fixed width of 50. Great works... but how do I resize the height to keep it at its original ratio?
    this.attachMovie(small_image, "number1_mcs" + loop , this.getNextHighestDepth(), {_x:50 + (loop*50),_y:300,_width:50,_yscale:?????????????});}
    many thanks in advance
    Dee

    Thanks for your help, being new, "terms", practices etc which others may fully understand, can fly right over ones head... It doesn't mean its impossible to understand them just grasping the exact meaning and then the specifics of any technicality can cause one to pull out more hair, especially when tired...
    I fixed the problem using the following... i hope its not too ugly..!
    Dee
    this.attachMovie(small_image, "number1_mcs" + loop_n1 , this.getNextHighestDepth(), {_x:75 + (loop_n1*40),_y:350});
    var aspect_ratio_x = this["number1_mcs"+loop_n1]._width;
    var aspect_ratio_y = this["number1_mcs"+loop_n1]._height;
    var aspect_ratio = (aspect_ratio_x / aspect_ratio_y);
    this["number1_mcs"+loop_n1]._width = 40;
    this["number1_mcs"+loop_n1]._height = this["number1_mcs"+loop_n1]._width / aspect_ratio;

  • Data Grid - issues resizing width of columns and with data refresh and sort

    SQLDeveloper 1215 on Windows XP professional
    Database : various 9.2
    In the table data tab there are a few minor issues our developers have highlighted.
    1) There seems to be a minimum column width in the data display. This restricts flexibility in reviewing the data, esp. where the data length is less than the minimum column width.
    2) If a column is resized or the column order is changed and a refresh or a new filter is applied then the columns are restored to their original position and size making it frustrating to run more than one query via the GUI.
    3) There is no quick sort option by clicking on the column heading which would be useful.

    I am still seeing this minimum column width in SQL Developer production (v1467) and I haven't seen any other posts relating to this. I have seen this all of the grids that I have looked at, including all of the grid based sub-tabs for the Object tabs (ie Columns, Data, Indexes, Constraints, etc) and the SQL Worksheet results tab.
    It is very obvious with the Column Name and Data Type columns of the Table Columns tab - the Column Name column can be shrunk to truncate values but the Data Type column can only be shrunk to about the twice the width of the widest value.
    Can anyone in development provide any comments about why we have this minimum width and how the minimum width is actually calculated?

  • Mac screen won't resize (width) in 1680x1050 setting.

    I clicked few other resolutions just to see the effect, when going back to 1680x1050 the screen is no longer full width. I clicked through them all and back again. No luck.  Snow Leopard 10.6.8.  Help.
    ATI Radeon HD 4670:
      Chipset Model:          ATI Radeon HD 4670
      Type:          GPU
      Bus:          PCIe
      PCIe Lane Width:          x16
      VRAM (Total):          256 MB
      Vendor:          ATI (0x1002)
      Device ID:          0x9488
      Revision ID:          0x0000
      ROM Revision:          113-B8030C-253
      EFI Driver Version:          01.00.367
      Displays:
    iMac:
      Resolution:          1680 x 1050
      Pixel Depth:          32-Bit Color (ARGB8888)
      Main Display:          Yes
      Mirror:          Off
      Online:          Yes
      Built-In:          Yes
    Display Connector:
      Status:          No Display Connected

    How did you delete the BootCamp partition?
    If you deleted it using Disk Utility, you have probably hosed up your disk.
    The only approved way to delete it is with BootCamp.
    Now you will probably have to repartition your disk to get the space back.
    Remember to back up first because the repartitioning wil destroy all data on the disk.
    Allan

  • Resize width of frequency graph on Project Documentation view

    I just installed the Labview Sound and Vibration 9.0 on a 64-bit Windows 7 PC. Now when I try to widen the frequency graph window only the handles drag out wider. The view remains the same size. how can I widen the view? Is this a 64-bit driver issue?

    In what control/VI/example were you trying to resize "the frequency graph window"? In order to help you better, please provide details as to the steps to reproduce and the observed behavior.
    As per the readme, Sound and Vibration Measurement Suite 2009 VIs fully support 64-bit platforms. Both LabVIEW 2009 and SVMS 2009 documentation indicate support for Windows Vista/XP/2000. Windows 7 had not yet released when the LabVIEW 2009 Platform released. LabVIEW 2010 and SVMS 2010 specifically add support for Windows 7, and all later software versions support Windows 7. If possible, upgrade to LabVIEW 2013 and SVMS 2013 as these are the latest releases with support for current operating systems, new features, bug fixes, and greater longevity of support. 
    Doug
    NI Sound and Vibration

  • Brush resize with [ ] deletes layer

    Hello, ALL!
        I have Photoshop CS4 x64 Extended installed on Windows XP x64 and there is a problem with resizing brushes with brackets []. Pressing these buttons leads to active layer deletion. Undo restores layer and resizing work ok for a while, but after some resizes or selection of another layer, the same error occures. I have 11.0.1 update installed. This error is actual for both x32 and x64 versions. Drag resize works fine.
        Did someone face the same issue and have a solution?
    Thanks in advance.
    Best regards / Ilya.

    If you are experiencing problems like that and you are in the laptop make sure to check the keyboard shortcuts and change them to some other key on your keyboard. This tutorial shows you how to:
    http://www.photoshopsupport.com/tutorials/jennifer/keyboard-shortcuts.html
    Let me know if you find this info useful,
    Vicente Tulliano

  • Adding resize handles to a rectangle to resize and drag in a canvas

    Hi
    I am having difficulty for the last couple days in getting a rectangle in java 2d to addshape handles to the corners which will allow me to resized the rectangle and then and dragged within the canvas using these handles. Also to get the shape on the canvas I will be clicking a button for the shape Rectangle to appear on the canvas in the first instance. I do not understand where I am going wrong.
    I am using the format of g2D.drawRect(10,10,50,50 ) for example to demonstrate my shape.
    Thanks in advance

    Search for
    draggable tjacobs01
    and
    resizeable tjacobs01
    these are my classes for doing what you're talking about. They work on components so you'll either have to switch your rectangles to components or adapt this code to non-component objects. It becomes more tricky because of the mouselistening.
    usage:
    Component c = ...
    new Draggable(c);
    new Resizeable(c);
    parent.add(c);

  • How to move and resize a whole layer with different objects and groups

    Ok, I am a bit confused here.Things are not working like I thought they would and the documentation has confused me more.
    currently in my code I have
    var embedLeftSleeve = new File(folderPath+"/LeftSleeve.ai");
    var leftSleevePlaced = doc.groupItems.createFromFile(embedLeftSleeve);
                            leftSleevePlaced.top = currentHeight;
                            leftSleevePlaced.left = 0;
    I am importing an AI file and trying to put it into its own layer. I want it (the imported ai file) into into it's own layer. And I would like the layer to be setup the exact way it was in the original. But, after the import it seems to group non-grouped items, some of the objects are not showing the same way they did (like a shape with a gradient fill in it).
    And finally, I want to scale all of the items in that layer as if I selected the layerer in illustrator and scaled it by hand (but scripting it to a set scale).
    Can someone please help me. I am digging deep into the documentations and looking all over online to find what I want with little luck.
    John

    Any chance of a sample of your art? I had a quick and my test art does NOT break up or look any different.
    I've been trying to build myself a set of library functions so my methods may appear a little odd.
    This was fine for me…
    #target illustrator
    var sleveArt = new File ('~/Desktop/Untitled-2.ai');
    var artName = sleveArt.name;
    var docRef = app.activeDocument;
    with (docRef) {
    pageOrigin = [0,0];
    rulerOrigin = [0,0];
    var docHeight = height;
    myLayer = layers.add();
    myLayer.name = artName;
    myGroup = myLayer.groupItems.createFromFile(sleveArt);
    myGroup.top = docHeight;
    myGroup.left = 0;
    resizeObject(myGroup, 140, 140, 100, 'BL');
    selection = null;
    function resizeObject(obj, sX, sY, clw, tr) {
    if (verifyObject(obj)) {
    var transAbt = getAnchor(tr);
    obj.resize(sX, sY, true, true, true, true, clw, transAbt);
    return true;
    function verifyObject(obj) {
    if (obj.typename == 'CompoundPathItem'||'GraphItem' || 'GroupItem' || 'PathItem' || 'PlacedItem' || 'PluginItem' || 'RasterItem' || 'SymbolItem' || 'TextFrame') return true;
    else return false;
    function getAnchor(x) {
    var thisTrans;
    switch(x) {
    case 'B' : thisTrans = Transformation.BOTTOM; break;
    case 'BL' : thisTrans = Transformation.BOTTOMLEFT; break;
    case 'BR' : thisTrans = Transformation.BOTTOMRIGHT; break;
    case 'C' : thisTrans = Transformation.CENTER; break;
    case 'DO' : thisTrans = Transformation.DOCUMENTORIGIN; break;
    case 'L' : thisTrans = Transformation.LEFT; break;
    case 'R' : thisTrans = Transformation.RIGHT; break;
    case 'T' : thisTrans = Transformation.TOP; break;
    case 'TL' : thisTrans = Transformation.TOPLEFT; break;
    case 'TR' : thisTrans = Transformation.TOPRIGHT; break;
    return thisTrans;

  • How do you resize just one layer & how do I make this layer not blur when enlarged?

    I am trying to drop a video game sprite into a much larger image and I wish to make the sprite bigger.  Every time I use CTRL + T  just to size the layer by dragging the mouse, once I hit the check mark it blurs the image instead of keeping it looking pixelated.  How do I avoid this?  (Using Elements 7)

    The following should help.
    1. Open your sprite and instead of transform (defaults to bicubic hence the blurring)
        use Image>Resize>Image Size set to resample-constain proportions-nearest neighbor)
        You will have to resize the sprite before you copy and paste (move) into the bigger image.
        The only hard part is setting the right size.
    2. After you resize then copy to your bigger image.
    Hope this helps.
    MTSTUNER

  • How to resize photoshop image without changing canvas size?

    When i had the older versions of photoshop i would change the image size and it would enlarge on my canvas for me to rearrange. Lately i realized on CC when i increase image size so does my canvas size. Is there anyway to prevent my canvas size from increasing too?

    I am having what appears to be this same issue.    I am using PS CC.  
    hello @ c.pfaffenbichler
    I resized my image in image> image size.  
    Details:
    I am not a ps expert but woefully self taught.  However through much trial and error I have in my experience over the years, achieved some comfortability with the image size dialog box as well as the canvas size dialog box.  SOME comfortability lol.  That is, I feel that I understand what is going on most of the time and when flummoxed have studied adobe literature or read hundreds of posts here and elsewhere to gain additional knowledge which many times resolves the issue.  I like digging and finding the answers.
    In this case, my digging is done dug a giant hole and I am exhausted and found nuthin'.
    I feel like I am going nutso.
    In my mind,
    1.  There is the image I am working on
    2.  There is the canvas the image is sitting on
    My expectation and previous experience is that I can change the Image size by going to Image > image size and this change does not affect the canvas size.
    My expectation and previous experience is that I can go to Image >canvas size and change the canvas size and this does not affect the image size.
    I could also use the Transform to resize the image which also, would not in my expectation, change the canvas size.
    In the beginning of my workflow on this particular collage I did not have this issue,  so that leads me to believe I did or am doing something to cause this rather than it being some kind of bug.    But what do I know.
    I thank you in advance for your assistance.

  • Move layer but keep layer within Canvas?

    Anyone can help me?
    Im not exactly sure how to describe my question correctly. But what I want is that when I move a selected layer eg to the left I want the parts that normaly goes outside of the canvas to appear from the right.

    Yes Photoshop is the never ending learning experance we all face. The onle reasion I knew about the was many yease ago I was intreaged at how well sone were able to stitch the up and down views in 360 Spherical panoramas. I read a turorial about it the first stitch a 360 with a whole top and botton the brought in the top and bottom and rotated the view so the top and bottom were now in the center and not so distored.
    PSD http://www.mouseprints.net/old/BigBen/pano.psd
    I gave up when I saw thyese that he did http://archive.bigben.id.au/victoria/virtual/vr/barmah.html

Maybe you are looking for

  • IMovie HD 1.0

    "iMovie HD, the video-editing component of the iLife ’05 suite, isn’t just a tweaked update to previous versions. Apple completely rewrote big chunks of the program’s code. Put another way, big chunks of the program are now at version 1.0." Ah, that

  • Who has had a problem with Zen Firmware upgra

    Its difficult when reading through the?message boards to get a true reflection of what is happening, clearly quite a number of people have had problems after and during the process of upgrading firmware, others clearly have not, I am interested to se

  • Dreamweaver changing symbols

    I'm using Dreamweaver CS3 for Windows on a MAC with Parallels (OS Lion). When I try to type the £ sign, Dreamweaver repalces it with a Hashtag, a symbol which does not appear on my Mac keyboard. Don't have this probelm in any other programme. How do

  • Cannot see users with server 10.7.3 update

    I updated to 10.7.3 and when I launch the server app I see only the administrator user in the users pane (all other users do not show up). Further, the knobs for + and - are grayed (disabled). I still can log in with any network user, though. How can

  • Data load component - add new column name alias

    Apex 4.2.2. Using the data load wizard a list of column and column name aliases had been created. When looking at the component (shared components/Data load tables/column name aliases) it is possible to edit and delete a column alias there. Unfortuna