Script Relative canvas size

I get just the shot of Photoshop scripts and have looked everywhere, but I can't find any way to change canvas size relative to the current Web using scripts.

My current script is less to... It defines a selection on the active layer and cultures / flattens the image. Now, I want to add a border of ten pixels compared to the size of the canvas. Does anyone have an idea how this could be achieved? I really don't want to have to create an action to run just resize the drawing area. Any help would be greatly appreciated!

layerPixels2Selection = function() {}

{if (App.activeDocument.activeLayer.isBackgroundLayer)}

Return End Function / / background isn't a transparency mask

}

var / / desc = new ActionDescriptor();

Var ref = new ActionReference();

ref.putProperty (charIDToTypeID ('channel'), charIDToTypeID ("FSC"));

desc.putReference (charIDToTypeID ("null"), ref);

var ref1 = new ActionReference();

Ref1.putEnumerated (charIDToTypeID ('channel'), charIDToTypeID ('channel'), charIDToTypeID ("TN"));

desc.putReference (charIDToTypeID ("T"), ref1);

executeAction (charIDToTypeID ('setd"), desc, DialogModes.NO);

}

demo

layerPixels2Selection()

app.activeDocument.crop (app.activeDocument.selection.bounds);

app.activeDocument.mergeVisibleLayers)

You can try this:

2012, use it at your own risk.

#target photoshop

If (app.documents.length > 0) {}

myDocument var = app.activeDocument;

var originalRulerUnits = app.preferences.rulerUnits;

app.preferences.rulerUnits = Units.PIXELS;

myDocument.resizeCanvas (myDocument.width + 20, myDocument.height + 20, AnchorPosition.MIDDLECENTER)

app.preferences.rulerUnits = originalRulerUnits;

};

Tags: Photoshop

Similar Questions

  • Script in Photoshop Actions for the canvas size?

    I have a variety of sizes of illustrations I want to post on my site;  that would take much less time if I could add a white border in Photoshop Actions by increasing the size of the canvas by 1/4 inch.  Thanks for your suggestions, BAB.

    Save a step size of canvas.  Leave the anchor point at the Center. Check relative and the value of 1/2 inch in width and height.  Photoshop will calculate the number of pixels needs to add to increase the width and height 1/2 "and add 1/4-inch canvas on all sides.  If there is a background layer in Photoshop the extra pixels will be 100% opaque and the color can be set in the canvas size dialog box. Can be set to the color of the background sample.  If there is no background layer, the added canvas will be empty.

  • A script to increase the minimum canvas size? (Like Image to adjust, but with just my canvas)

    First to be clear, I'm looking to manipulate the size of the canvas. No image size.

    I want to create a script to automatically increase the width and the height of my canvas in Photoshop to a size specific, when necessary. I don't want that to happen if my canvas is smaller than the specified size. For example: Let's say my canvas size is 300 x 250. I want the Web to be at LEAST 600 x 600. If I run my action, it will increase the size of the canvas to 600 x 600 for me. If I run this same script on an image where the size of the canvas is already 700 x 700, it did nothing for her because the width and height are equal to or greater than the size of my target.

    She will also work with the height and width on an individual basis. If my image is 400 x 800, the action would increase my width of 400 to 600, but he let the height of 800 only. If the final canvas size will eventually be 600 x 800.

    It's a bit like the option 'Adapter the Image' in Photoshop, but I want only to manipulate the size of my canvas, NOT the size of my image.

    You can try this:

    // resize canvas in either direction if it is below a defined minimum;
    // 2011; use it at your own risk;
    #target photoshop
    if (app.documents.length > 0) {
    var myDocument = app.activeDocument;
    // set to pixels;
    var originalRulerUnits = app.preferences.rulerUnits;
    app.preferences.rulerUnits = Units.PIXELS;
    // set the minimum values;
    var minWidth = 600;
    var minHeight = 600;
    // get current ones;
    var theWidth = myDocument.width;
    var theHeight = myDocument.height;
    // resize canvas;
    myDocument.resizeCanvas(Math.max(minWidth, theWidth), Math.max(minHeight, theHeight), AnchorPosition.MIDDLECENTER);
    // reset;
    app.preferences.rulerUnits = originalRulerUnits;
    };
    
  • Resize an image to fill the canvas size according to height?

    Hi guys,.

    Is it possible to resize a picture to fill the canvas size according to height?

    Currently when I place an image, it fits on width, being a landscape on a canvas portrait image I need to fill the height.

    Any suggestions on the best way to do it, maybe an action?

    Thank you

    Gavin

    If the image containing or the picture may vary in dimensions/dimensions a Scripting approach would seem prudent.

    In the contrary case, a conditional Action may be enough.

  • Why the my canvas size is bigger than my work plan?

    Hello

    I'm working on a larger project, where I have mulitple PSDs linked in a single document. The individual DSP that have all plans of work that are the same size, but in inspection of the size of the canvas on these documents vary considerably in size.

    This causes me some discomfort because:

    -When you place the PSD files in the main document, the bounding box of the PSD is much larger than the graphics I want to place.

    -Second, if I want to resize the size of the canvas on the current related DSP, I am trying, it shrinks the chart down much more that what I would actually. This causes me to have to change the size of each graphical element, which sometimes can be quite tedious.

    In my view, that the size of the canvas should be able to resize the artboard size I'm working on, if only when I have a single work plan I'm working on (which is currently the case).

    Is there a way to adjust PS for the canvas size will correspond to the size of the artboard? Whereas if I adjust the length of the arboard, the size of the canvas reflects the change in size?

    Thank you.

    Unfortunately, it is still an open question in our backlog of work.

    The following workaround solution is clumsy, but should work:

    1. choose the tool work plan.

    2 Unger, the gear icon, deselect auto size canvas. This setting affects only the current document.

    3. adjust the size of your canvas as needed using the Image-> canvas size command. It will remain at that size until you change it again manually.

    Work plan documents do not show the extent of the Web, but there are ways to see: layers of filling (with disabled auto-nid) under all work plans, for example.

  • Image adjustment and canvas size does not

    Hello world

    I'm trying to save an action on an open image. I first choose the command "Mount Image" and enter a size of 1580 x 2000 pixels (do not expand). I then choose the size of the canvas and try and enter the dimensions in pixels of 1580 x 2000 pixels but although I input these numbers, when I view the details of this step of action of canvas, he always says height: 2000 pixels, Vertical: Center, but it does not the width of 1580.

    It seems that for some reason any program won't allow me to enter the same dimensions in pixels in two separate measures, consecutive. I remember successfully made this a few weeks ago, but I don't know why it doesn't work now.

    I was wondering if someone could help me out and let me know what I could do wrong?

    Thanks in advance.

    I have never see that happen if you change the two dimensions of the canvas. can you show a screenshot if registered in the palette step actions. Here what I get... If you want to save the step size of canvas after made stage image to save on both sides, you need to change both one side will be 2000 or 1580.  So, you need fix this first. stop recording changes the size of the canvas to 1581 x 2001. Then start of new record replaces canvas size to1580x2000.

    When you record steps if you do not change a default option offered Photoshop will not record anything for this option and Photoshop uses its default value.  It's very important when you want things like the name of the current document to use other options as the current path to use. If you change only the saved value will always be used.   Here you want you still want the canvas image size to be extended to the full 1580 x 2000 therefore with other reports l / h of images will focus on a canvas of 1580 x 2000.

    Package of shares of crafts UPDATE August 10, 2014 added conditional measures Action Palette tips.
    Contains

    Example of
    Download

  • Get/apply the canvas size

    I do some scripts cleaning for some processes of photoshop where I work and thought in a way to eliminate the duty change actions but am not sure that the characters used to perform actions.  What I need is a script that will get the size of the canvas of a single document (I'll call him original.psd for easy reference) and apply it to another document without damaging or resize the layers (I'll call her what a target.psd).

    I already have most of the script, so I just need the lines that will be

    (a) get the canvas of original.psd size and

    (b) applies that the canvas size to target.psd

    Thanks in advance for any help!

    DGolberg

    Need a script to a document of reference before you can work with it. You're not telling the order, that the images have been opened or their names. The code below will get the size of the canvas of the first open document and apply it to the second open.

    var w = app.documents[0].width;// the width of the first open document
    var h = app.documents[0].height;
    app.activeDocument = app.documents[1];// make sure the second open document is active
    app.activeDocument.resizeCanvas (w, h);
    

    If you want the order of the just switched document exchange the 0 and 1.

  • Canvas size problem?

    Hi, I currently have a problem with the size of the canvas? The problem is that when I select the background layer and choose Image-> canvas size is opening a fine, and I can even make changes to my size, anchor point, and even choose the color of background extension.  However, when I click OK it resizes all the layers and compensates even some of them instead of resizing just the backdrop.  So now, I have a background layer that is all just white and and a layer of model that has just a single sheet on her image.  The two layers are currently 79 x 89 px.  I select the background layer and choose image-> canvas size and change the width to 200 px and height to 200px and make sure relative is not checked, then choose an anchor centeral and white for the extension background color and click OK.  What happens if is that when it is resized in the background, she changes the model layer as well which was centered on the original background, he still retains centered sheet, but he adds also some parts of the sheet to the four corners of the background as it offset some parts of the model layer. In addition, the two layers are now 200px X 200px instead of just the bottom layer of ideas?  The post is long sorry I just wanted to make sure there's enough information that can provide a clear picture of the problem I had.

    I think that maybe what is happening is that you don't realize that layers can keep information beyond the borders of the canvas, and you can not see.  What you do when the increase in the size of the canvas are revealing information that was already there.  You can get information there if you, for example, paste a larger image as a layer.

    You can force Photoshop to throw all the information beyond the edges of the canvas before taking the canvas to change size by doing something like the following:

    1 Select the crop tool from the Toolbox.

    2. make sure that nothing is specified in the width, height, resolution fields at the top of the main window of Photoshop.

    3. slide the tool completely around the image, so that all the visible part of the image is surrounded by.

    4 Note the cropped area at the top of the main window of Photoshop setting.  Set it to delete rather than hide.

    5. complete the crop tool by clicking on the check mark.

    Now, when you increase the canvas size there will be no data previously hidden beyond the edges of the canvas.

    -Christmas

  • Canvas size Bug/Feature

    In previous versions of PS defining a Web of smaller size that the current image is crop all layers, now that the base layer is cropped. It's probably better than what PS has done previously, but why change now when people have libraries of scripts that could be (and have been in my case) broken by this change? I mean if it was OK to do it for the eleven first versions surely making selectable as it would have been a better choice just to change it with no option to maintain compatibility with the previous behavior?

    function() {return A.apply (null, [this] .concat ($A (arguments)))}

    CraigAmey wrote:

    In previous versions of PS affecting a painting of less than the current image size would harvest all layers

    Your assumption (or terminology) seems to be wrong.  The behavior you describe (maintenance of the data beyond the current canvas layer) has been around for a very long time.

    Just to be sure, I was not remembering wrong (as I'm becoming SOME afterall) I just tested on CS5, CS4, CS3, CS2, CS and 6.0.

    Large image with layers, Image - adjust - size of the small canvas, then return the canvas size to enlarge.  All data was still there (except that the expanded background area was filled with the background color).

    -Christmas

  • iMovie canvas size

    Someone knows how to change the canvas size in iMovie to 750 x x 1334 h?

    iMovie 10 works in 16:9 format, but 750 x 1334 is 09:16.   You could change on the side then turn it after sharing, but of course titles would be a problem.  You must create them in another application with s with transparent background .png or .jpgs with green background and then use the installation of the green screen

    Geoff.

  • "Canvas size" does not remember last setting used

    I noticed that "Canvas size" does not save the last settings used more in Photoshop CC 15.5. It is located in centimetres every time.

    The "Image size" option screen keeps the last used settings.

    This used to work properly in Photoshop 14 CC.

    Canvas size always comes back to the unit which is defined in Edition > Preferences > units & rulers.

    "Image size" in the upper part of the window always the size in pixels and under the print format, but never shows in pixels.

    If your preferences setting is "mm", the print size will be shown in mm.

    If your preferences setting is "pixel", the print size will be shown in cm or mm or inches, but not in pixel.

    Fenja

  • What canvas size should I create in Photoshop for the titles of 4K for the cinema?

    I know the resolution, but question canvas size?

    I believe that 4K is available in different flavors.  Safer would be 1920 x 1080 x four, up to 4096 x 2160

    As always, Wikipedia is the source of all knowledge

    4K resolution - Wikipedia, the free encyclopedia

  • Should what the canvas size I use for my project of e-Learning 8 Captivate?

    Hello world!

    The maximum size of my e-learning project is 740 x 555, so that it can adapt to the size of the LMS. E-Learning has a Table of contents and the skin Editor, but of cause I want to use as much fabric as possible.

    It's been a while since I worked with Captivate and has a fragile memory of the published version adds a few pixels. Is it still OK for 8 Captivate?

    Canvas size what do I use to make e-Learning made the LMS, but always include the Publisher of skin and OCD?

    ARO

    Madeleine

    Are you talking about a normal or sensitive project? Is the table of contents separate or overlay? If it is separate, it will add 250px width if you change the width of the table of contents that is now possible. Ditto for the playback bar: is that overlay or not? If this isn't overlay, the number of pixels added to the height depends on the chosen playback bar. You can check its height by looking at the width of the bottom border in the skin Editor. This lower border fits the selected playback bar.

  • Why keep my canvas size smaller than what I get in the boxes?

    I did a book cover for a printing company and they have come back to me twice now - basically, I think that the measures are not good and they may not format correctly for printing.

    The Web is supposed to be 316mm wide and 216mm in height, with a 300px dpi. However, when I look at how big the Web is (Image > canvas size) he always says 315.98 215.98 x, no matter how many times I try to resize it. I'm not entirely sure how printing doing things, but I think this 0.2 mm could make a difference. The same happens when I create a new file. I want to do a 3 mm x 210 mm canvas, because I need a margin of 3mm on each edge (where the extra 6mm in width and height of the A4 size 310 x 210). However, this new canvas is also then 2.96 x 209.97 mm. So when I want to use it as a guide on the edges, I'm a total of 0.8 mm - so I think this could really make a difference.

    I tried to search to see if anyone had the same problem but couldn't find anything. It would be nice if it's just a problem I supervise and allows to correct quickly. Printing needs coverage again as soon as possible, so a quick response would be great.

    I use:

    • 8.1 Windows 64-bit (up to date)
    • Photoshop CS6 13.0.1 x 64

    At 300 dpi, would become 316 mm ~ 3732,28 pixels. Since you need an integer pixel value, the result is the rounded 3732 pixel dimension. Return calculated, which would be ~ 315,98 mm.

    Benjamin

  • Custom canvas size?

    Is it possible to change the default canvas size in the Sketch in Adobe Photoshop or Adobe Illustrator online? It would be particularly useful when it comes to the import and paste the other files in the document and not have to worry about issues of scale and size.

    If this isn't the case, I think it's something that needs to be addressed if Adobe is seriously to do right mobile applications.

    and now, our amazing product manager found time for us and the official response is:

    [note as short answer] to sketch the canvas size is the size in pixels of the iPad (2048 x 1536) when you make a shipment of Photoshop.

    We finally have it

Maybe you are looking for