Pasting from a script centers the image

Hello,
I'm new to these formus and to extendScript in particular, and I would be verry happy if someone could point out what I'm doing wrong.
I have a script that opens a image (lets call it icon), and for all the images in a folder, resizes icon to the current folder image, pastes the image on top, and saves it.
It works great except for a small problem which I can't seem to fix. When the image from the folder is smaller than the canvas ej:
Then when the image gets copied over the icon image, it's pasted centered, like this:
Which defeats the purpose of what I wanted to do, I needed it pasted in the same position as it was in the original image. As we are talking of well over 1k images, doing this by hand is a bit problematic, so I would be really thankful if someone could help me out.
Here is the script:
#target photoshop
app.bringToFront();
function main()
    var iconFile = File.openDialog ("Select the base (icon0) file", "*.png", false);
    var inputFolder= Folder.selectDialog ("Please select folder to process");
    if(inputFolder == null) return;
    var fileList = inputFolder.getFiles("*.png");
    var outFolder = Folder(inputFolder +"/Processed");
    if(!outFolder.exists) outFolder.create();      
    // Open icon file and create a new layer, making the background one invisible
    var icon = open(iconFile);   
    var artLayerRef = icon.artLayers.add()
    icon.layers[1].visible = false;
    for(var z in fileList)
        // Open icon file
        var icon = open(iconFile);
        var artLayerRef = icon.artLayers.add()
        icon.layers[1].visible = false;
        // Open 32 bit file
        var img32 = open(fileList[z]);
        var img32Name = decodeURI(fileList[z].name.replace(/\.[^\.]+$/, ''));
        // select all document
        img32.selection.selectAll();
        img32.selection.copy();
        // Copy image to the icon layer
        activeDocument = icon;
        icon.resizeImage (img32.width.value, img32.height.value);
        icon.paste();
        // Save icon with name
       var saveFile= File(outFolder + "/" + img32Name + ".png");
        Save24 (icon, saveFile);
        // Clear layer, close open image
        icon.selection.selectAll();
        icon.selection.clear();       
        img32.close();
    icon.close(SaveOptions.DONOTSAVECHANGES);
main();
function Save24(doc, saveFile)
     pngSaveOptions = new PNGSaveOptions();
     doc.saveAs(saveFile, pngSaveOptions, true, Extension.LOWERCASE);

Hy Michael,
first, thank you for taking time to reply. I apologize for how confusing the post is, I realize how hard it is to understand by code, so I'll try it with images to make it clearer.
Here is the original icon file:
// Open icon file
        var icon = open(iconFile);
        var artLayerRef = icon.artLayers.add()
        icon.layers[1].visible = false;
And now we open the first img32 file (sorry for the size, it's a bit hard to see but there is a small green hill on bottom left)
// Open 32 bit file
        var img32 = open(fileList[z]);
        var img32Name = decodeURI(fileList[z].name.replace(/\.[^\.]+$/, ''));
Then we select the img32 and copy it:
// select all document
        img32.selection.selectAll();
        img32.selection.copy();
And then we resize the icon document to fit the img32 size:
// Copy image to the icon layer
        activeDocument = icon;
        icon.resizeImage (img32.width.value, img32.height.value);
Finaly we paste on the icon the img32 content we had copied:
icon.paste();
Notice how the img32 contents get copied smack in the center? I needed to copy it in it's original position, not the center.
You can probably see the problem with working with translate, as I can't figure out the displacement the image needs. All images I need to work are different sizes and positioned in random positions in the canvas, so I can't hack it to be always bottom right or something like that, I need it in the original position.
Any tips? Your help is greatly appreciated, and frankly, the only hope I have about this whole busines right now.
Thanks again.    

Similar Messages

  • Firefox upon opening an image in a new tab, centers the image from top and bottom and surrounds the image with a grey frame. Just started having the problem today, searched Google to no avail.

    Firefox upon opening an image in a new tab, centers the image from top and bottom and surrounds the image with a grey frame. Just started having the problem today, searched Google to no avail.

    Oh wow, looks like a new feature.
    The "page" links in a stylesheet with the address "resource://gre/res/TopLevelImageDocument.css". If you remove that reference, then the image displays in the old style.
    '''''Edit: Please skip the rest of this post and check out the next one.'''''
    There might be a more elegant solution than that, but you could use a bookmarklet to strip out that link when you want to view the page in its old style. A bookmarklet is a snippet of JavaScript you save on the Bookmarks toolbar for quick access.
    First, copy the following code to the clipboard (it's all one long line):
    <br>javascript:var ssheet=document.querySelector('link[href="resource://gre/res/TopLevelImageDocument.css"]'); if(ssheet)ssheet.parentNode.removeChild(ssheet); void 0;
    Next, if you are not displaying the Bookmarks Toolbar, use View > Toolbars > Bookmarks Toolbar to display it. (If you aren't using the classic Menu bar, press Alt+v to call up the old View menu. Right-clicking the gray area just below the page address also allows you to display the Bookmarks Toolbar.)
    Right-click on the Bookmarks Toolbar (or Mac equivalent of right-click!) and choose New Bookmark.
    Paste the code into the Location box (the second box).
    Then type a useful name in the Name box (e.g., Oldstyle Picture) and click Add.
    Now, when you want to tweak the image display, click the button to run the script.
    Manual clicking is a hassle, so it might make sense to look into other solutions. (Greasemonkey didn't seem to work; I think it might not run on .jpg files.)

  • I just installed the new firefox for Mac OSX 10.6.8 and when I select an image on a site (right click and copy) and paste in Photoshop 5.5, the image lightens. It does not do this in Safari.

    Question
    I just installed the new firefox for Mac OSX 10.6.8 and when I select an image on a site (right click and copy) and paste in Photoshop 5.5, the image lightens. It does not do this in Safari.

    Firefox, Safari, and PhotoShop each handle embedded color profiles differently. For an add-on that makes it easier to experiment with Firefox's color management options, you might be interested in: [https://addons.mozilla.org/en-US/firefox/addon/color-management/ Color Management :: Add-ons for Firefox]. I haven't tried it myself.

  • How to get the parameter from Java Script into the Parameter crystal Report

    Hi All,
    Crystal Report is integrated with Oracle 10g. I created the base SQL query for col1, col2, col3 and col4. Java Script pass parameter value (185) to Col1.
    My question is how to create crystal report to make Col1 as parameter and how to get the parameter value 185(Col1) from Java Script. Is there any additional code I need to include in the crystal report?
    FYI.
    Java script sends the right parameter value.There is no issue in java script.
    This is an automatic scheduled process when batch runs, Java script should pass the parameter value and the crystal report should get the value and produce the output report.

    Not sure if this is an application question or if you are trying to hook into Crystal Reports parameter UI? If the later then no option other than report design. If an application then I can move this to the Java Forums.
    If you are asking how to alter the parameters I suggest you remove the Java reference and post a new question so it's not confusing the issue.
    Please clarify?

  • How to load images in List from Xml and view the image and resize the image & save in Flex?

    Hi Friends,
    I am new to flex i am doing application for image resizing rotating and save the resize image.
    I want to load the images from xml file to listcontrol and show that images as a icon in the listview,then i want to drag that image to panel that time it should show it original size of the Image.then it allows user to resize ,crop,rotate the image.then i want to save the resize image,when i save the resize image it should replace the original image in the xmllist.
    I am looking for some useful suggession ,if you dont mind want to see some snippet code.
    It will help me to understand the concept.
    Cheers,
    B.Venkatesan

    Not in Crystal Reports Basic for Visual Studio 2008. You'll have to upgrade to CR 2008 (12.x). Then use kbase [1320507|http://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/oss_notes_boj/sdn_oss_boj_erq/sap(bD1lbiZjPTAwMQ==)/bc/bsp/spn/scn_bosap/notes.do] as a guide on how to do this.
    Ludek

  • Centering the image on 4x6 paper.

    Still trying to print an image on 4x6 paper with a border and I cannot center the image. It makes no difference if I hit the "center" button.
    I've gotten the latest Epson drivers for my MAC (Lion).
    Also makes no difference if I "crop to fit", or not.
    The image and borders look fine on the computer screen, but will not print what the screen shows.
    Anybody have any ideas?
    Richard

    I did that; makes no difference. Still gives me no border on top, and 3 differenrt size borders on the other 3 sides. Makes no difference if I click "center" or not.
    It looks perfect on the computer screen when I "center" it, but it doesn't print the way the screen show.
    It also makes no difference if I click "crop to fit" or not.
    I'm using PSE 9, on Lion MAC, with Epson 1280 printer.
    It seems like the most basic thing that a PSE program should do is to center a print. In the past I've used this same printer with Photoshop, and no problem.

  • Printing from a applet toolbar the image displayed in the applet

    Hi ,
    I have a JApplet which displays a tiff image. The applet uses JAI API and Java 2D for printing. I can zoom in . zoom out , invert the image and I am printing the displayed image also .
    In the action handler class for the print button , I have made an inner class implementing printable and executing the print function.
    I am doing printing via a separate thread as i don't want my action handler class to keep waiting till the image gets printed . The user should be able to manipulate the image after it has clicked on the "ok" of the print dialog, while the image is being printed. This is the reason for printing the image in a separate thread
    and the actual printing process is a synchronized method called by the run method of the thread .
    If I click on print button twice , one after another , the second image gets printed only after I get a response from the printer that image has been printed as expected (as the print method is synchronized ).
    In the action handler class of print , I do not call join on the thread as I do not want it to wait for printing to get over ( printing of a tiff image actually takes a long time ?? )
    Is there anyway to make the threads independent of the main applet . Like after firing the print command , if I close the applet and I haven't got a confirmation from the printer, I get a blank page or nothing but i get a response message from printer that printing is done .
    Is it essential for a thread to wait till the printer sends a response that printing is over ?
    Similarly , If after firing the printing command and without waiting for the confirmation from the printer , I refresh the applet , proper printing does not occur but I get a message from the printer that printing is done .
    If i use synchronized method for printing and wait till the printer response from the printer comes without closing or refreshing the applet , printing occurs fine .
    Can anyone please tell me what is actually happening and is there a better way to print and that printing occurs after the print command has been fired irrespective of the applet ?
    Regards , Navneet

    Hey can you send me the code for the same. I know its been a long while, but I am new to JAI and need the same stuff u coded. u can mail it to me on [email protected]
    Thanks in advance.

  • I need to replace a color on my image with a specific color from another part of the image.  How?!

    I have spent over 2 hours trying to figure out how to replace a color on one part of my image with a specific color shown on another part of the image.  So far I have been able to go to "Replace Color" on my Adobe Photoshop version, but it seems that I can only change the hue and brightness of the color that it currently is.  I need to use a specific color so this does not help me.  Does anyone know how to complete the task I am referring to?
    Also, please keep in mind that I am using Adobe Photoshop 6.0, not a fancy cs version or anything.  So it's pretty old school...
    Any help/feedback is greatly appreciated!  Thank you.

    Hi brookehelene,
    You might consider making a selection the object and using a color fill layer set to the color blend mode instead of replace color.
    I used the same picture as kendallplant did and changed the color on the same flower by sampling the pink color from the flower to the right)
    (click on the screenshots below for larger views)
    1. Select>Color Range
       (i used color range because the dialog is somewhat similar to the replace color dialog, except one is making a selection instead of replacing a color)
       (there are many other ways to make the selection such as the magic wand, so if your more familar with the other selection tools you can use those instead to make your selection)
    2. Use the eyedroppers and fuzziness slider in the color range dialog to make the selection of the object.
       (in the screenshot below the white areas are selected and black areas are not)
       (your selection probably won't be perfect, but you can paint on the layer mask to refine the selection)
    3. After you press the okay in the color range dialog you'll see the selection (marching ants)
       At the bottom of the layers palette press the Create New Fill or Adjustment Layer icon
       to reveal a list and choose Solid Color.
       Then use the eyedropper to sample a color from your image and press ok.
       Change the Blend mode for the color fill layer to Color (top of the layers palette)
    4. As you can see a lot has been selected besides the flower.
        To refine the areas of color, paint on the layer mask with the paintbrush tool.
        Use white to add the color or black to subtract the color
        You can press the D key on the keyboard to get the default colors (black and white) in the toolbox
        and press the X key to switch between the two when painting on the layer mask.
    Even though the above takes longer you can easily change the color or modify the areas that you want to change the color on.
    To change the color you can double click on the color fill icon in the layers panel.
    You can also use other layer blend modes besides color such as hue, so you might try some of the others and see what they do.

  • When I go from LR to PS, the image gets very noisy.

    Going from LR to PS, I get a lot of noise.  There are other differences as well.  It seems the WB is a little different, too.  I've made sure the color profiles are the same, but that seems to not make a difference with this isssue. 

    I am starting with a RAW file from my Canon 6D.  I make corrections in LR and then go to 'edit in Adobe Photoshop CC 2014' for further editing.  When it opens in PS, it looks quite a bit different.  The images were taken in very low light and I used pretty heavy noise reduction in LR.  It looks great in LR, but it seems to not really be applied in PS.  Here are screenshots.  The PS image is first and LR second.    

  • Why does removing an anchor point from this line reshape the image?

    Hi,
    I tried removing an anchor point from a semi-circle, but removing the anchor point reshapes the image.
    Video of it here:
    Anyone know how I can correct it? The semi-circle is a portion of a circle that remained after I had removed a portion, so reshaping it by moving the remaining anchor point will not do, as it will not create that perfect semi-circle.

    Can you first change to outline view then select the anchor point in question with the direct selection tool and post a screenshot of the outcome (with guides showing). Just want to see if there is a handle point attached and then this may be the reason why. It may be worth using the delete anchor point tool instead of the eraser.

  • How do you copy and paste from an iMac of the internet

    Hello,
    Pleas scan you help me?
    I don't know how to copy and paste of the iMac, to pages from the internet?
    Thank you,
    luciewills

    Press command + control + shift + 4
    When the crosshair pointer appears drag it across the area you want to copy and then click it.
    Open the application where you want the copy to be placed.
    Then    File > Paste
    http://support.apple.com/kb/ht5775
    Best.

  • How to send output from SQL script to the specified log file (not *.sql)

    ## 1 -I write sql command into sql file
    echo "SELECT * FROM DBA_USERS;">results.sql
    echo "quit;">>results.sql
    ##2- RUN sqlplus, run sql file and get output/results into jo.log file
    %ORACLE_HOME/bin/sqlplus / as sysdba<results.sql>>jo.log
    It doesn't work please advise

    $ echo "set pages 9999" >results.sql ### this is only to make the output more readable
    $ echo "SELECT * FROM DBA_USERS;" >>results.sql
    $ echo "quit" >>results.sql
    $ cat results.sql
    set pages 9999
    SELECT * FROM DBA_USERS;
    quit
    $ sqlplus -s "/ as sysdba" @results >jo.log
    $ cat jo.log
    USERNAME                          USER_ID PASSWORD
    ACCOUNT_STATUS                   LOCK_DATE  EXPIRY_DAT
    DEFAULT_TABLESPACE             TEMPORARY_TABLESPACE           CREATED
    PROFILE                        INITIAL_RSRC_CONSUMER_GROUP
    EXTERNAL_NAME
    SYS                                     0 D4C5016086B2DC6A
    OPEN
    SYSTEM                         TEMP                           06/12/2003
    DEFAULT                        SYS_GROUP
    SYSTEM                                  5 D4DF7931AB130E37
    OPEN
    SYSTEM                         TEMP                           06/12/2003
    DEFAULT                        SYS_GROUP
    DBSNMP                                 19 E066D214D5421CCC
    OPEN
    SYSTEM                         TEMP                           06/12/2003
    DEFAULT                        DEFAULT_CONSUMER_GROUP
    SCOTT                                  60 F894844C34402B67
    OPEN
    USERS                          TEMP                           06/12/2003
    DEFAULT                        DEFAULT_CONSUMER_GROUP
    HR                                     47 4C6D73C3E8B0F0DA
    OPEN
    EXAMPLE                        TEMP                           06/12/2003
    DEFAULT                        DEFAULT_CONSUMER_GROUPThat's only a part of the file, it's too long :-)

  • How to pass tables data from SAP script to the routine.

    Hi,
    I have standard program RPCTEAL0_01 which calls a SAP script form(Custom) to print the form.
    Now I have to add some additional functionality to change the values in the form. Since it is custom form I can add ROUTINE and then pass the values to the custom program to modify the variables.
    My concern here, I would like to pass the tables like RT,CRT to the custom program via form.
    Is this possible?  RT and CRT filled by standard progam.
    Regarsd
    Eswar
    <MOVED BY MODERATOR TO THE CORRECT FORUM>
    Edited by: Alvaro Tejada Galindo on Jan 20, 2009 9:06 AM

    Hi, The suggested option is not working.
    Actually I am using the below code in SCRIPT
    /:   PERFORM CAL_2008 IN PROGRAM ZHR_TEST1
    /:   USING &PER_NO&
    /:   CHANGING &W12&
    /:   ENDPERFORM
    and calling form in ZHR_TEST1. But this will pass only variables. Now my requirement is to pass tables also.

  • Need help with getting images to look smooth (without the bitmap squares) around the edges. When I transfer the image from pictures, it sets itself into the InDesign layout, but with square edges. I need to find out how to get it to look smooth?

    Need to find out how to get my images transferred into an InDesign layout without the rough edges, as with a bit map image, but to appear with smooth edges in the layout. I can notice it more when I enlarge the file (pic). How can I get it to appear smooth in the finished layout. Another thing too that I noticed; it seems to have effected the other photos in the layout. They seem to be
    pixelated too after I import the illustration (hand drawn artwork...)? Any assistance with this issue will be greatly appreciated. Thanks in advance.

    No Clipboard, no copy & paste, as you would not get the full information of the image.
    When you paste you can't get the image info from the Links panel, but you can get resolution and color info either via the Preflight panel or by exporting to PDF and checking the image in Acrobat.
    Here I've pasted a 300ppi image, scaled it, and made a Preflight rule that catches any image under 1200ppi. The panel gives me the effective resolution of the pasted image as 556ppi. There are other workflow reasons not to paste—you loose the ability to easily edit the original and large file sizes—but pasting wouldn't cause a loss in effective resolution or change in color mode.

  • I am unable to email an image from camera roll. the image gets "stuck". cannot input email address or subject line. am unable to cancel and go back to camera roll

    i am unable to email images from my camera roll. the image gets "stuck". cannot insert email address or subject line. cannot cancel... return to camera roll.
    what to do. i tries taking new picture and sending it in an email... same thing... gets "stuck "
    Waht to do ?

    Hello lohmann8,
    Thank you for providing so much detail about the issue you are experiencing with emailing photos from the Camera Roll.
    The first thing I recommend is quitting and relaunching the applications on your iPhone:
    Double-click the Home button.
    Swipe left or right until you have located the app you wish to close.
    Swipe the app up to close it.
    You can find the full article here:
    iOS: Force an app to close
    http://support.apple.com/kb/ht5137
    If you are still seeing the same issue after quitting and relaunching the Photos and Camera app, I recommend restarting your phone and then resetting if it's still not working:
    Restarting your device
    Press and hold the Sleep/Wake button for a few seconds until the red "slide to power off" slider appears, and then slide the slider.
    Press and hold the Sleep/Wake button until the Apple logo appears.
    Note: Reset your device only if you are unable to restart it.
    Resetting your device
    Press and hold the Sleep/Wake button and the Home button together for at least ten seconds, until the Apple logo appears.
    You can find the full article here:
    iPhone, iPad, iPod touch: Turning off and on (restarting) and resetting
    http://support.apple.com/kb/ht1430
    If the issue persists, the last thing I recommend is backing up and restoring your iPhone:
    iOS: How to back up and restore your content
    http://support.apple.com/kb/HT1766
    iTunes: Restoring iOS software
    http://support.apple.com/kb/HT1414
    Thank you for using Apple Support Communities.
    Best,
    Sheila M.

Maybe you are looking for

  • Installing Oracle Application Server 10g 101202 on Windows 2008 64 bit

    Hi All, what i need to do is install this software like this: installing Oracle Infrastructure to handel Sessions as db for oracle forms & reports install Oracle Forms & Reports Service as Middle-Tire on the same machine in defirent home configure my

  • Bad sound in my x-fi audio after windows upd

    I have accidentally downloaded this @ windows update on tuesday? Creative - Sound - Creative X-Fi Audio Processor (WDM)Creative Sound sofware update released in June, 2007? After that all my sound options were gone and i have a terrible bad sound. Is

  • Issue using Letters

    I am currently using PCM 14 and BI Publisher 11g. The issue i am having, is with BI Publisher. I am trying to create a letter for a project, but when i press create letter, i recieve an error. oracle.xdo.webservice.exception.OperationFailedException:

  • Multiple Animations

    Hi I was just wandering if you can play 1 animation 'on top' of another. I have created a scene in 3D and the user has complete control of the camera and can view all around the scene. I then have lots of animations for the user to view from a menu.

  • Can i use the debit card details for payment in the itunes store

    can i use the debit card details for payment in the itunes store