Last active
December 31, 2015 01:09
-
-
Save iKlsR/7912609 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// units setup, doesn't matter eventually | |
var originalUnit = preferences.rulerUnits; | |
preferences.rulerUnits = Units.PIXELS; | |
// create a new document (size doesn't matter) | |
var docRef = app.documents.add(128, 128); | |
// get the current layer (background) | |
var topLayer = app.activeDocument.layers[0]; | |
app.activeDocument.activeLayer = topLayer; | |
// rename/unlock it as it is locked by default | |
app.activeDocument.activeLayer.name = 'Unlocked'; | |
try { | |
// paste from the clipboard | |
docRef.paste(); | |
// delete the background layer | |
topLayer.remove(); | |
// reveal the entire document | |
docRef.revealAll(); | |
{ | |
// fit to screen snippet from http://forums.adobe.com/thread/980700 | |
var id57 = charIDToTypeID("slct"); | |
var desc15 = new ActionDescriptor(); | |
var id58 = charIDToTypeID("null"); | |
var ref6 = new ActionReference(); | |
var id59 = charIDToTypeID("Mn "); | |
var id60 = charIDToTypeID("MnIt"); | |
var id61 = charIDToTypeID("FtOn"); | |
ref6.putEnumerated(id59, id60, id61); | |
desc15.putReference(id58, ref6); | |
executeAction(id57, desc15, DialogModes.NO); | |
} | |
} catch (e) { | |
alert("Clipboard is either empty or doesn't contain a valid image.\nThe document will close.\n\n"); | |
docRef.close(SaveOptions.DONOTSAVECHANGES); | |
} | |
// restore original ruler unit setting | |
app.preferences.rulerUnits = originalUnit; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment