Stretching / translating a layer into another document

I have probably just my math, but given a limit of area of selection (or limits), I'm trying to resize it so that it is the size of a paper target, and then translate it so it is in the upper left corner, taking up the entire screen (so what is in the square selection occupies the entire screen.  Now if I duplicate the layer in the same document and resize it using the dimensions of the document and translate, it fills the entire screen.  However, if double layers in a target, document and scale and translate according to its dimensions, the layer is the right size, but madly out of position (most of the time off the page).  I think that the translation would be independent of the destination doc and based only on the magnitude and (minX, minY) from the selection box.

Is my math off or y at - it something funny on duplicate a layer in another document?  I guess this is the first, but I continue to do it in my head and the math seems reasonable.

var layer = app.activeDocument.activeLayer;
layer.isBackgroundLayer = false;
var layers = new Array (thumbnails.length);
layers [0] = layer;
for (var i = 0; i < layers.length; i ++) {}
layers [i] = layer.duplicate (documentTarget);
}

var srcDocument = app.activeDocument;
app.activeDocument = documentTarget;

for each layer, through translation and resizing based on the size of the box
for (var i = 0; i < layers.length; i ++) {}
var selectionBox miniature = [i];


var scaleX = documentTarget.width.as ("px") / (selectionBox ['maxX'] - selectionBox ["minX"]);
var scaleY = documentTarget.height.as ("px") / (selectionBox ['Christmas'] - selectionBox ["minY"]);




layers [i] .resize (scaleX * 100, scaleY * 100, AnchorPosition.TOPLEFT);
layers [i] .translate (new UnitValue (-selectionBox ["minX"] * scaleX, 'px'),)
new UnitValue (-selectionBox ["minY"] * scaleY, "px"));
}





}

}

.. Why would it be different if the layer is duplicated at the topleft of the paper target to 0,0 minX, minY?

This is the point I was trying to do. This assumption is inaccurate. The duplicated layer is not 0,0 unless the two documents are the same size and resolution. To chip away at layer is centered in the new RFSO. Only when the sizes correspond to the positions will match. Otherwise the new top-left position could be anywhere including canvas (negative values).

If you do not want to change the minX, minY, for some reason, you could add code to align the layer to the top left before the line translate.

function align(type){
   var desc = new ActionDescriptor();
     var ref = new ActionReference();
       ref.putEnumerated( charIDToTypeID( "Lyr " ), charIDToTypeID( "Ordn" ), charIDToTypeID( "Lnkd" ));
   desc.putReference( charIDToTypeID( "null" ), ref);
   desc.putEnumerated( charIDToTypeID( "Usng" ),charIDToTypeID( "ADSt" ), charIDToTypeID( type ) );
   executeAction( charIDToTypeID( "Algn" ), desc, DialogModes.NO );;
};
function alignTopLeft(){
  align("AdTp");
  align("AdLf");
};
app.activeDocument.selection.selectAll();
alignTopLeft();
app.activeDocument.selection.deselect();

Tags: Photoshop

Similar Questions

  • After hiighlighting a Word and paste it into another document, the Clipboard does not; When I hit enter again and again blocks. How should I do?

    When I select a word or phrase and copy to the Clipboard, then paste it into another area of the Clipboard does not erase the expression. Therefore, every time that I type and press the Enter key it continues paste the sentence throughout my document. I have the latest download of Firefox are installed (16.0, win 7 and that's when it started.) How to stop this heinous behavior so I can type a sentence with normality?

    Louise

    Try Firefox Safe mode to see how it works there.

    A way of solving problems, which disables most of the modules.

    The problems of Firefox using Firefox SafeMode

    When in Safe Mode...

    • The State of plugins is not affected.
    • Custom preferences are not affected.
    • All extensions are disabled.
    • The default theme is used, without a character.
    • userChrome.css and userContent.css are ignored.
    • The layout of the default toolbar is used.
    • The JIT Javascript compiler is disabled.
    • Hardware acceleration is disabled.
    • You can open the mode without failure of Firefox 15.0 + by pressing the SHIFT key when you use the desktop Firefox or shortcut in the start menu.
    • Or use the Help menu option, click restart with the disabled... modules while Firefox is running.

    To exit safe mode of Firefox, simply close Firefox and wait a few seconds before using the shortcut of Firefox (without the Shift key) to open it again.

    If it's good in Firefox Safe mode, your problem is probably caused by an extension, and you need to understand that one.

    http://support.Mozilla.com/en-us/KB/troubleshooting+extensions+and+themes

    When find you what is causing that, please let us know. It might help others who have this problem.

  • Script to copy layer in another open Document/group?

    Hi, I know that this topic has been covered several times before. But to clarify, here's what I asked:

    Copy the active layer/group into another document opened in Photoshop. The easiest way is to go to the «layer/double layer...» ». But it is very tedious. To begin with, when you choose this method and then select the document you want to copy in the menu drop-down, successfully, copy the layer/group for this document, but it is not auto-switch (unlock) in the document, he just copied in. You have to hit 'Ok', and then manually search through the open documents list via (window / * choose your document *) to get there. It is a nightmare when you try to do several times.

    Here's what I asked:

    It is possible to:

    (a) copy the active layer/group in the Clipboard/memory

    (b) switch to another document in Photoshop * via a personalized menu * which shows all existing documents

    (c) one time positioned on the new document, paste this layer/group from the Clipboard into this document

    .. is this possible?

    At the very least, is there scripts that anyone knows of that allows the user to switch between existing documents via a custom instead of going to the window menu / * choose your document *?

    Hi @boo radley 2013.

    do you mean something like this?

    // LayerPaste2anotherDoc.jsx
    // https://forums.adobe.com/thread/1496531
    
    // regards pixxxelschubser
    
    var aDoc = app.activeDocument;
    var AllDocs = app.documents;
    var actLay = aDoc.activeLayer;
    
    if (AllDocs.length > 1) {
    var itemDoc = null;
    actLay.copy ();
    
    var win = new Window("dialog","Copy the active layer");
    this.windowRef = win;
    win.Txt1 = win.add ("statictext", undefined, "Paste in which open document?");
    win.NewList=win.add ("dropdownlist", undefined, AllDocs);
    
    win.NewList.selection = 0;
    itemDoc = win.NewList.selection.index;
    
    win.cancelBtn = win.add("button", undefined, "Abbruch");
    win.quitBtn = win.add("button", undefined, "Ok");
    win.defaultElement = win.quitBtn;
    win.cancelElement = win.cancelBtn;
    win.quitBtn.onClick = function() {
    win.close();
    }
    
    win.NewList.onChange= function () {
        itemDoc = win.NewList.selection.index;
        return itemDoc;
        }
    
    win.show();
    
    app.activeDocument = app.documents[itemDoc];
    app.activeDocument.paste();
    app.refresh();
    } else {
        alert ("No other documents open")
        }
    

    Have fun

  • I received a text document that went into another language, how it translate to English?

    I received a text document that went into another language. I don't know what language it is. How to get English, so that I can read it...?

    * original title - please help! *

    Go to a page of internet translator like Bing Translator or Google Translate and paste the body of the text file in the text box for the foreign language. This can be done by opening the text document by pressing on Ctrl + A (e.g. Select) then Ctrl + C (e.g. copy). Then, place the cursor in the new place and pressing Ctrl + V (for example the dough). Let the program automatically detect the language of the source if you are not sure of its origin, and then click translate to the English equivalent.

  • Copy of 5 layers (or a set of layer) to another open document

    Hello

    I have 2 open documents. The former has 5 layers. I need these 5 layers to the second open document. And that's my problem. The 5 layers creates a composition. So if I copy one by one, the position related to other layers will change.

    In my script tried linking layers before copying. Without success. Tried to create a layerSet, but did not find any method to copy this layer defined in the second document :/

    No idea how to copy the 5 layers of another document?

    Thank you very much

    Gustavo.

    Using copy and paste or layer.duplicate? Duplicate will retain all the data layer including position. If the documents are of the same size and the res, dupped layer will be in the same place, they were in the original document.

    If you copy and paste you need to get the layer boundaries in the original Victorinox then use layer.translate to move them into the correct position after the paste.

  • Move a layer from one document to another, I get the error message that the layer is empty

    When I copy a layer from one document to another in PS CC 2015.5 and then try to move the layer in the destination document, I get the error message that the layer is empty.  It is not empty and I checked several times and checked that the layer is not empty.  I have never had this problem before and wonder if something has changed in CC 2015.5.

    Thanks to all who responded.  I think the problem was that I was using the NEF files and that he had not yet renamed PSD files.  Copy the layer in the destination document, but when I tried to move the layer in the destination document, I received the error message.  Apparently, he was copying the layer but there not then recognize the NEF format.  Once I saved both documents to the PSD, then the program behaved normally.  I appreciate your all of the help.

    Sue

  • I just want to move a layer of document in Photoshop to another document that has a visible tab in the upper area

    I just want to move a layer of document in Photoshop to another document that has a visible tab in the upper area

    Ensuring that the layer is active, Ctrl (Cmd on Mac) + A to select all. CTRL (Cmd) + C to copy. Switch to the other document. CTRL (Cmd) + V to paste.

  • I dragged a cutout of the image of a photoshop document into another, and now she is blurred. What should do?

    I dragged a cutout of the image of a photoshop document into another, and now she is blurred. What can I do to prevent this?

    What is the resolution of the image that you "dragged"? The resolution is the number of pixels per inch (DPI). If you dragged a file of much lower resolution to a higher resolution file, it could result in a blurry image.

    See below:

    To learn more key Concepts:

    http://www.Adobe.com/DesignCenter-archive/KeyConcepts/articles/concept_resolution.html

    You can determine the size of the image by choosing Image > Image size

    below you can see the dimensions in pixels of my image for example.

    Basics of the resolution:

    Adobe TV - http://tv.adobe.com/watch/creative-sweet-tv/photoshop-resolution-basics/

    http://TV.Adobe.com/watch/Visual-design/getting-started-09-resizing-an-image/

    Adobe Help:

    http://help.Adobe.com/en_US/Photoshop/CS/using/WSfd1234e1c4b69f30ea53e41001031ab64-7945a.h tml

    -janelle

  • (UNSOLVED) Layer duplicated in another document

    Hello, honorabe participants of the forum scripts Photoshop!

    I have a problem - How to implement/action script duplication of the two layers related from one document to another document already open? The linked layers is a specially formatted text, so I can not just copy - paste the in the open document. Document already open is a CR2 file.

    When I record the action, PS also save the receiver document name. But the name change when I open another folder so all acation jumps.

    PS can record 'Select next 'document' and "Select previous document", but can't ' save 'duplicate layers in previous document ".

    Please, help me to solve my problem.

    Hey Borizzzed,

    You try to run it on multiple files (ie: use this solution in a batch process)?  I do something very similar to the work; but I'm not sure of linked layers.  You will need to put them in a group for them to stay connected as I do.  In any case, the code I use is below:

    #target photoshop

    activeDoc var = app.activeDocument; This option stores the currently active document in the activeDoc variable

    var originalDoc = app.documents.getByName ("source.psd"); This option stores your .psd source file name Photoshop may find the layers that you want to copy in the appropriate document.

    var theLayer = originalDoc.layerSets.getByName ("text"); This option stores the group that you want to copy in the other document to a variable named theLayer

    app.activeDocument = originalDoc //Switches to the active document to the document source for the duplication is possible only in the document further.

    var theCopiedLayer = theLayer.duplicate (activeDoc, ElementPlacement.PLACEATBEGINNING);  This puts the Group at the top of the layer stack in the target document.

    If you try to batch run this; just save the script in action and add a save option, then perform this action with the lot.  Also, if you are running it in the form of lots; don't forget that the source .psd is open before starting the batch job.  Anyway, give it a try and let me know if it works!

    dgolberg

  • How can I drag a layer in one document to another while retaining information from posts?

    Hi all

    I was using PSD for a while now and it's pretty frustrating.

    Do you know how can I drag a layer in one document to another while retaining information from posts?

    Normally when you drag a layer of document A to B, the layer just fall randomly.

    Any ideas?

    See you soon,.
    Venn.

    So, I thought about it.

    Drag the layer + hold SHIFT key. Once the layer is the right document, drag and release the SHIFT key.

    - - -

    Note: 2 documents must have the same size of canvas in order to preserve positions. If they are not the same, the removed element will be centered in the middle of the canvas.

  • How I changed the color of something? OK, so I use to be able to change the color of things, but now I have use color overlay, gradient overlay, or change the color when I first create the form, it turns into another shade of gray instead of chan

    How I changed the color of something? OK, so I use to be able to change the color of things, but now I have use color overlay, gradient overlay, or change the color when I first create the form, it turns into another shade of gray instead of change the color, I chose.

    Three things I can think of:

    Your document must be in RGB mode.

    Layer blending mode should be set to Normal

    Masks are grayscale. If you select the mask, you cannot apply a color.

    Always check your tab at the top to see if what you choose is RGB or grayscale.

    Gene

  • Copy the work plan (and art) to another document

    Is it possible to write a script to copy a graphic Board selected/chosen (and its contents) to another document open, placing exactly in the same place on the global x / y coordinates?  I am unable to find this feature in Illustrator, or it is simply missing.  Any help is greatly appreciated.

    Thank you!

    Tim

    Hi Tim, this is, open your model and your destination document and run the script

    #target illustrator
    
    // script.name = timLCdupArtboards.jsx;
    // script.description = duplicates provided artboards to another open document;
    // script.required = requires CS5, and both source and destination documenets (with the same layer structure) open
    // script.parent = CarlosCanto // 02/07/12;
    // script.elegant = false;
    
    // Notes: use only in documents with NO sublayers, 
    
    var docList = doclist(); // get a list of open docs
    
    var source = prompt ("Enter Source Document (Index Number)\r\r" + docList, 0, "Copy Artboards"); // get source doc name index
    if (source!=null) {// quit if pressed Cancel
        var dest = prompt ("Enter Destination Document (Index Number)\r\r" + docList, 1, "Copy Artboards"); // get destination doc name index
        if (dest!=null) {// quit if pressed Cancel
            var absstring = prompt ("Enter Indexes of Artboards to copy (comma separated)", "25,37,16,19,34,35,36", "Copy Artboards"); // get list of artboards to copy
            if (absstring!=null) {// quit if pressed Cancel
    
                var artbs = absstring.split (","); // turn list into an array
                var absCount = artbs.length; // get artboards count
    
                var sourceDoc = app.documents[source]; // get actual docs
                var destDoc = app.documents[dest];
    
                // get layer visible/lock info & unlock and make visible all layers
                var sourceDocLayerState = unlockUnhideLayers(sourceDoc);
                var destDocLayerState = unlockUnhideLayers(destDoc);
    
                sourceDoc.activate(); // activate source otherwise it is not able to access selection
    
                var ABs = []; // array to hold of artboard objects to copy
                var ABsRect = []; // array to hold artboards Rectangles
                var ABsNames = []; // array to hold artboard names
                var ABsInfo = []; // array to hold [Rect, Names]
                for (i=0; i		   
  • cpy/paiste group in another document

    Hello forumers.

    Im trying to copy/paiste my group (of 10layers) of a document of ps in another.is it possible?
    IM by selecting all its paisting in my another document, but all the layers are merged.i need to come into the document as a group with all its layers.

    Thank you.

    Select the Group and choose layer > Group duplicate... and duplicate the document you want in the group. Otherwise, you can drag and drop one document to another group using the move tool.

  • 'Create page vew' in another document, both documents are open

    In Adobe Acrobat 9 Pro, I want to create a link in the document 1 page view display a passage in 2, but after I created the link to the page, when you click on closing the document 1 link (the same thing happens in 10 Pro).

    This does not happen when I create a link "open a file", which translates the two files remain open (Yes, I select 'new window' which documents link).

    The only steps that I can see to follow are 'create link'-> select the page in the current or other document - to go to a Page view popup menu menu 'fixed '. After I do that the link is created, but when you click on the current document closes.

    Can I change the settings by default so that I can keep two open documents?

    It is possible to do it, Yes, but unfortunately only after you have created the link.

    Right click on the link (using Add or change the link), and then select Properties. Switch to the Actions tab and change the action "Go to a page in another document" which is there. Under 'Open In' select 'New window', and then click OK.

    Another thing you can do is to go to editing Documents - Preferences - and uncheck "open the cross-documents links in the same window.

    This means that if the link is configured to use the preferences of the user, the file will open in a new window. But if the link is set to open in the same window, it will not make a difference.

  • I need to convert PDF into Word Document, so it can be edited. But grateful text options do not have the language I need. How can I convert the file in the desired direction of my language?

    I need to convert PDF into Word Document, so it can be edited. But grateful text options do not have the language I need. How can I convert the file in the desired direction of my language?

    The Acrobat application provides no ability to language translation.
    If you locate the language for the applications from the OS, MS Office, Acrobat, etc. to the desired language try again.
    Alternative: transfer a copy of the content in a web site based in PTE (Bing or Google offers a free service).
    Transfer the output in a word-processing program that is localized in the appropriate language.
    Perform the cleaning.

    Be well...

Maybe you are looking for

  • Satellite Pro 6000; sleep function does not work after upgrade W98 SE to XP

    I bought a windows XP cd and installed on W98 on my Satellite Pro 6000. The sleep function does not work now. I probably need a software of Toshiba. What do I need? Where can I find? What is the order of installation?

  • Re: ads

    $9.88 credit and advertising. Is it possible to revert to the version I was using before this update? We try to protect our children consumerism and inappropriate content, and now they must face together when they want to visit their grandparents.

  • Look at HDR-as10 camera

    Is there a cord or a way to see what I'm shooting on my I phone 5 or anyway to use it like a regular camera?

  • Regular expression matching is not what matches Pattern

    I read a lot of posts on how match model does not match what match regular expressions will be due some characters does not. However, I found a problem with the other way. A simple Reg - Ex who works in the match pattern but not regular Expression ma

  • After a clean install can I still get updates

    I came to the conclusion that I have to do a clean install and the company for the model mark I finally sent the operating system after 4 years now that I have (xp media center) came with sp2... but some how the jerk who took an illegal copy of xp pr