trying to script copy-new file / paste (ctrl-a, ctrl-c, ctrl-n or ctrl-v)

I am a multilayer PSD file and selecting different layers, so I can export in PNG.  I have a few layers with small images, the rest of the canvas is transparent.

I want just the non-transparent area (like Ctrl-A, Ctrl-C Ctrl-N and Ctrl-V does).  The problem with doing this is that I have no way of knowing what the POSITION of the image.

So, I put got it from layers in Photoshop CS6, and then run a script:

#target photoshop

app.bringToFront ();

app.activeDocument.selection.selectAll ();

app.activeDocument.selection.copy (true); want to seize all visible layers into the Clipboard

var calcWidth = app.activeDocument.selection.bounds [2] - app.activeDocument.selection.bounds [0];

var app.activeDocument.selection.bounds = calcHeight [3] - app.activeDocument.selection.bounds [1];

var docResolution = app.activeDocument.resolution;

var myNewDoc = app.documents.add (calcWidth, calcHeight, docResolution, undefined, NewDocumentMode.RGB,

DocumentFill.TRANSPARENT);  the selection is the size of the FULL image, not the region active selection.

myNewDoc.paste ();

I don't see how to get the x, y of the selection goes to the Clipboard.

In this case I would jump using the Clipboard.

function newDocFromMergedLayers( docName ) {
    var desc = new ActionDescriptor();
        var ref = new ActionReference();
        ref.putEnumerated( charIDToTypeID('Dcmn'), charIDToTypeID('Ordn'), charIDToTypeID('Frst') );
    desc.putReference( charIDToTypeID('null'), ref );
    desc.putString( charIDToTypeID('Nm  '), docName );
    desc.putBoolean( charIDToTypeID('Mrgd'), true );
    executeAction( charIDToTypeID('Dplc'), desc, DialogModes.NO );
};
newDocFromMergedLayers( "newDocName" );
var mergedBounds = app.activeDocument.activeLayer.bounds;
app.activeDocument.trim( TrimType.TRANSPARENT);
alert(mergedBounds[0]+' : '+mergedBounds[1]);

Tags: Photoshop

Similar Questions

  • I just copy a file by ctrl + c then I'll stick with ctrl + v, that after I copy the file (b) by ctrl + c and paste ctrl + v and once again if I need to paste everything first: to leave what shortcut I use

    I just copy a file by ctrl + c then I'll stick with ctrl + v, that after I copy the file (b) by ctrl + c and paste ctrl + v and still, if I need to paste everything first: to leave what short cut I have we

    On Mon, 24 Sep 2012 15:49:08 + 0000, ajay8055 wrote:

    I just copy a file by ctrl + c then I'll stick with ctrl + v, that after I copy the file (b) by ctrl + c and paste ctrl + v and still, if I need to paste everything first: to leave what short cut I have we

    You can't do it without third-party software. Just go back and
    Copy the file (a).
    Ken Blake, Microsoft MVP

  • I have a list of files on the left side and I am trying to create a new file. Whenever I create a new file, it will in a list/topic - as creating a

    All I want to do is create a new file and do appear in my existing list of files instead of a new file under a new title.

    I am trying to create a new file and it appears in the sent column where my files for e-mail are listed. Now he goes over these files under a different title every time creating a new file.

  • Why whs 2011 installation gets stuck to copy Windows files on the HARD drive?

    I try to install WHS 2011 OEM on a HP EX470 software.  I have tried about 30 times without supervision and welfare facilities in the past 4 months and am very frustrated that I can't succeed and purchase the software was a waste of time and money.  I tried 4 hard drives, properly formatted capacity of 250 GB to 2 TB.  EX470 has the original 1620 AMD processor and 2 GB RAM upgraded and qualifies for the upgrade to a 64-bit system.

    Problem with installation assistance tries: Installation says "Copying Windows files", but after a variable time in hours of waiting, growth remains at 0% and finally says "error in installation.  Try to restart the installation.  Same thing happens with the help of the DVD, or by using a Sandisk Cruser formatted and made bootable 16 GB flash drive with a file cfg.ini the instructions online and also tried without the cfg.ini file.
    Problem with unattended installation attempts:  Process completely blind.  Does not install even if left for 24 hours.  Cannot decipher the flashing lights on the Flash drive and thereafter, no installation nor evidence of partial installation is visible on check the hard drive on another computer.  I suppose that the same thing as the installation attempts assisted.
    Looked for solutions online for 4 months, but nobody does the problem of Windows not to copy the files to the HARD disk during installation and what goes wrong.
    Help!

    Hello

    I suggest you post your question to the link and check.

  • Photoshop CS5 won't open the psd files or new files Please HELP!

    I'm fairly new to Photoshop. I have it on my Mac. I tried to open a file that I worked on earlier and Photoshop opened and I saw all my layers on the right, but the window with the actual image did not come to the top. I thought that maybe he had a problem with the file, so I tried to open a new file, but I had the same problem. He showed the background layer, but I could not see the real picture. I don't really know what to do. Can anyone help?

    The GPU is the graphic processing unit - the heart of your video card.

    OK, 10.7 has lots of video driver bugs, and some of those that have been set in 10.7.3. You have installed all OS updates?

    If Apple doesn't have a fix for the bug pilot yet, you can disable OpenGL drawing in Photoshop preferences to avoid driver bugs, but you lose some features also.

  • Copy and paste the folders only paste the new files

    Hello

    I copy a folder (contains several subfolders and files) and paste it into another file, the old file is updated every day with a new file and I copy the entire folder and paste it in later.

    I want to know if it is possible to paste only the files and folders that are present in the old folder and not the folder later in time quick.

    The total size of the file is 40 MB and the new added files on a daily basis are less than 1 MB. So I want to do for the new files so that it can be bonded quickly.

    RP

    You cannot copy paste files files that are present.  You can move and then allow those you want and exclude those that you do not.

  • I can't create new tabs by file-new tab or Ctrl-T

    When I go to the new file tab-, nothing happens. Same thing when I try Ctrl-T. File-new window works. I tried to restart.

    Hello

    Please open a topic: empty in a new tab, press CTRL + T , although it is active. If it does not, then one of your extensions could be the cause, please see questions to troubleshoot Firefox in Safe Mode and troubleshoot extensions, themes and problems of hardware acceleration to resolve common Firefox problems.

    The "Ask Toolbar" is specifically known to cause this problem with Firefox 3.6.13, you can try to disable in tools-> Add-ons-> Extensions and restart Firefox.

  • I'm trying to copy picture files from C: to D: readers. How can I do

    I need more space on my C: drive and you want to copy the image files on the D: drive and remove them from the C: drive.  I can't find a solution on how to do it.  BACK was easy, but there seems to be no program for that.

    Two ways:

    • Open a Windows Explorer window and navigate to the directory that contains the image files
    • Open a second Windows Explorer window and navigate to the drive D:\ (or to a new folder that you create on D: using file > New > folder).
    • Drag and drop in the 2nd window.  See http://windows.microsoft.com/en-US/windows-vista/Moving-and-copying-files-by-using-the-drag-and-drop-method you can do this one at a time or select multiple files using the CTRL or SHIFT key.  If you use the right instead of the left mouse button while you drag, you'll get a menu that allows you to choose whether you want to MOVE or COPY (best practice is to COPY then DELETE after that you don't know the copy did what you wanted;) MOVE automatically deletes the source files after their copy to the destination).

    Or

    • Open a Windows Explorer window and navigate to the directory that contains the image files.
    • If the left pane of the window does not display a list of common tasks, make sure that the button 'search', or the 'Files' button in the explore toolbar is selected.
    • Select the files to copy/move, using CTRL or SHIFT as you wish
    • Under "file and folder tasks", click on "copy this file.
    • Navigate to the destination folder, and click "copy."
  • Creating text file use new file, by returning the result by completely removing the lines of code to extend script?

    Hi guys

    Creating new files .txt in extendscript thru new file returns results by removing all the code in extend script.

    Example of

    -------------------

    var fPerCode = 'hack ';

    var myFileP = new File($.fileName);

    var myFilePtS = myFileP.parent.fsName.toString ();

    myFileP.open ('w');

    myFileP.write (fPerCode);

    myFileP.copy(myFilePtS+"\\"+"Mytools_icons"+"\\"+"name.txt");

    myFileP.close ();

    Alert ("path to the fullper.bat file" + "\n"+myFilePtS+"\\"+"Mytools_icons"+"\\"+"name.txt");

    If you run the above code, you see the result by disabling all of the code above.

    can someone help with this problem?

    You have a problem that you are writing your own script file and then doing a copy...

    You also toString() of unnecesery and deformities (+).

    Here is a fix your code:

    var fPerCode = 'hack ';

    var myFileP = new File($.fileName);

    var myFilePtS = myFileP.parent.fsName;

    var myNewFile = new File (myFilePtS + "\\Mytools_icons\\name.txt");

    myNewFile.open ('w');

    myNewFile.write (fPerCode);

    myNewFile.close ();

    Alert ("path to fullper.bat file\n" + myNewFile.fsName);

  • Photoshop CS6: image is too large when cut and pasted on a new file window.  I'm cut a picture of 2 x 3 on a new file, and it reads like 8 x 11 or more. How

    Photoshop CS6: I cut and paste a small part (2 x 3 inches) of an image on another new file window (8 x 11).  The transferred image appears huge. If I reduce the size, the whole image and reduced background, not only the image. How can I keep the image of 2 x 3 and keep the size of the canvas of 8 x 11?

    Thank you

    The transferred image appears huge

    Caircraft are 2 x 3 image is higher resolution than your 8 x 11 file.

     
    Change the resolution of the 2 x 3 to match you res 8 x 11 before you copy it to the new file or

    Choose this layer in the copied file and then edit > transform > scale. Be sure to hold the SHIFT key while you move the handles to angle to maintain the proportion.

    If your copied file appears even more of your 8 x 11, see angle of the scale handles, press Cmd + 0 (which is zero) to display the handles

  • Could not copy a file at the location requested. Mac OS 10, Version 10.10 [1].  I JUST bought this new macbook pro and Lightroom installed, imported 2 lots of pictures, but all of a sudden he kept denying my imports with "could not read the file" or "coul

    Could not copy a file at the location requested. Mac OS 10, Version 10.10 [1].

    I JUST bought this new macbook pro and Lightroom installed, imported 2 lots of pictures, but all of a sudden he kept denying my imports with "could not read the file" or "couldn't copy file at the location requested.  Help, please!

    Your use of the word "files" (in the plural) still makes me believe that you have not checked the permissions on the folder that is appropriate (in the singular).

    You must determine the Destination of the Lightroom Import dialog window Panel and see which folder Lightroom is really tr6ing to copy photos in (which may have been accidentally changed and is not what you may have used in the past) and change the permissions to write to this folder.

  • Cannot open new tab by going to the file/new tab (or CTRL + T or by clicking on the new field of the tab). One is to right-click on a link and choose open in a new tab.

    Cannot open new tab by going to the file/new tab (or CTRL + T or by clicking on the new field of the tab). One is to right-click on a link and choose open in a new tab.

    I found that the ASK toolbar is the culprit. I have no recollection of ever install Ask and wanted not just her in any case. Withdrawal fixed the problem.

  • Why can't I managed to install the iso file in my USB? I've tried different usb and hard drives and disassembled a lot or time usb but when, it comes up with an error copying the files on and it stops loading? What should I do?

    Why am I unable to download and copy iso files that need to go into the USB drive, it always comes up with an error when copying the installation files and none of the solutions have worked (some of the things I've tried are different from the USB, disassemble and repeat the download process windows files)

    You cannot use a simple USB as a source and destination. You must copy the ISO file (it's a single file, not the full installer) in your Documents folder and then run BCA to create a USB installation program. 2015 macs do not create a USB installation program.

    Please visit https://help.apple.com/bootcamp/assistant/6.0/ .

  • I can script volume shadow copy service files to copy VSS files to another server?

    Hello

    Wanted to ask if it was possible to take the info created by VSS and move it to another server? The reason why I ask is that I need to information to a file on a backup server, copy it to another standby server and have it ready to go when the original bang goes machine!

    While enjoying the fact than expected jobs work fine with the backup software and can copy the file backup due to another server as a :-) scheduled task I can't put automated restoration work to restore back this folder on a daily basis by using the backup of windows server or backup exec (very annoying!). I was wondering if I could create shadow copies of the file/volume concerned on the original server, and then have a script that has copied the files on the backup server?

    Just in addition, the concerned files/folders are usually left "open" or "locked" (these include mdb files too!) so just using xcopy etc will not work :-(

    Any ideas or suggestions would be welcome :-)

    Thank you very much for your help

    Kevin

    I suggest that you take cela Server TechNet or TechNet IT Pro forums.  This forum serves users with Windows home versions.

  • Error: Copy Photos "Windows has encountered a problem wen trying to copy this file.

    original title: copy files confuses computer!

    When I try to copy photos on my drive E or D (which I've done a thousand times) it now says ' widows has encountered a problem when trying to copy this file "... What do you do? ".. . as I have a shaky choice! ' cos it gives the options... How *, it's that ' cos they must be aware of * advertising but feel so safe in their ivory towers! What's wrong. Help, please. MikeW

    There are two approaches you can take.

    One solution: you can copy files into smaller "chunks" until you identify the file that causes the error, and then try to find out what is the problem with this file.

    Another solution is to download the program "Robust copy" (Robocopy) to Microsoft and it allows to copy your files.  You download and install in the Windows 2003 Resource Kit (works fine on XP).

    Windows Server 2003 Resource Kit:
    <>http://www.Microsoft.com/en-US/Download/details.aspx?ID=17657 >

    Once installed, you can open a command prompt window (start-> Run-> "cmd") and enter the command:
    Robocopy "C:\photos" 'E:\photos' /R:5 / s
    Where "C:\photos" will be replaced by the source directory, and the 'E:\photos' is the destination directory.  the "/ S" option will copy the subdirectories and the R:5 option retries 5 times on error before moving on to the next file.  Errors should be displayed on the screen and I found errors of command line to be more descriptive than GUI errors.  There are a lot more options, but this should help you get started.

    HTH,
    JW

Maybe you are looking for

  • Change the order of Podcast episodes

    Hello. I wish I had my eps podcast playing high down, as right now the ep albums is number 67 but I would so he could play at the 1 and keep going down. Is there a way to do this? I went to iTunes, click on the tab release date for the podcast and it

  • Error Code 80071AA7

    I received the automatic update of windows Vista and another program and tried to update and receive error code 80071AA7. I could not find data on this code on microsoft. Thoughts, or ideas what this code means?

  • HP pavilion laptop computer: enter the password administrator or power on password

    Hello! When I start my laptop it comes a message saying that the administrator to enter password or power on password. After that three attempts he said disabled with a code 75595776 system. Please help me.

  • CLJ 5550dn: fuser for CLJ 5550dn

    I have trouble finding the correct fuser for my HP CLJ 5550dn printer. I need one with cutouts for the release of unit eliminator levers discharge of static electricity. Is there a part number special for this merger? I ordered the Kit merger HP 645

  • Is it still useful to install SP2 for Vista on 64-bit system? What are the benefits?

    OK, so I have Windows Vista Premium Home Edition on a laptop HP with Service Pack 1 installed. I have disabled the automatic updates of Windows functionality, because there are so many unnecessary and space-hogging updates that I can't be bothered. I