Skip to content

Instantly share code, notes, and snippets.

@cg-method
Last active September 6, 2019 04:54
Show Gist options
  • Save cg-method/c44dad4950e5043578aa1398d55aa4fa to your computer and use it in GitHub Desktop.
Save cg-method/c44dad4950e5043578aa1398d55aa4fa to your computer and use it in GitHub Desktop.
【Photoshop】選択したレイヤーを別ドキュメントに複製するスクリプト
preferences.rulerUnits = Units.PIXELS;
var doc= activeDocument;
var layer= doc.activeLayer;
var name = layer.name;
var w = doc.width;
var h = doc.height;
var b = doc.activeLayer.bounds;
var x1 = parseInt(b[0], 10);
var y1 = parseInt(b[1], 10);
var x2 = parseInt(b[2], 10);
var y2 = parseInt(b[3], 10);
var newDoc = documents.add(w, h, 72, name, NewDocumentMode.RGB, DocumentFill.TRANSPARENT);
activeDocument = doc;
layer.duplicate(newDoc);
activeDocument = newDoc;
newDoc.crop([x1,y1,x2,y2]);
newDoc.layers.getByName('レイヤー 1').remove();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment