Copy link to clipboard
Copied
Hello,
Maybe it's a stupid question but is there a way to create an art layer (whose kind is LayerKind.NORMAL) wider than the actual document?
For exemple, if my active document is 800 x 600 pixels, I would like to create an art layer of 1000 x 800 pixels.
At least, I could to that by:
1 - getting size and resolution of active document
2 - creating a temporary new document with desired size at the same resolution
3 - copying the background of the new document
4 - pasting it in my original document
5 - closing without saving the temporary document
But it doesn't seem to be a very clean process. Furthermore, it would erase any previous clipboard's content.
1 Correct answer
I can suggest doing so
var w = 1000;
var h = 800;
var tmp = preferences.rulerUnits;
preferences.rulerUnits = Units.PIXELS;
activeDocument.artLayers.add();
var c = new SolidColor() ;
c.rgb.hexValue = "FFFFFF";
activeDocument.selection.selectAll();
activeDocument.selection.fill(c);
activeDocument.selection.deselect();
activeDocument.activeLayer.resize(100*w/activeDocument.width.value, 100*h/activeDocument.height.value);
preferences.rulerUnits = tmp;
Explore related tutorials & articles
Copy link to clipboard
Copied
I can suggest doing so
var w = 1000;
var h = 800;
var tmp = preferences.rulerUnits;
preferences.rulerUnits = Units.PIXELS;
activeDocument.artLayers.add();
var c = new SolidColor() ;
c.rgb.hexValue = "FFFFFF";
activeDocument.selection.selectAll();
activeDocument.selection.fill(c);
activeDocument.selection.deselect();
activeDocument.activeLayer.resize(100*w/activeDocument.width.value, 100*h/activeDocument.height.value);
preferences.rulerUnits = tmp;
Copy link to clipboard
Copied
You should have no problem add a new empty layer and filling it with a color and then transform its size to what you want using the correct percentages for the width and height. In this case 125% wide and 133.33% high if the layer had an image it would distort because the the percentages are not the same. Here I add a green layer under a red canvas size layer and transformed the green layer. I then ran a script the added guide to the layers bounds.
Copy link to clipboard
Copied
Thanks to both of you, it works
A smarter solution than the one I was thinking of.

