What's new
Photoshop Gurus Forum

Welcome to Photoshop Gurus forum. Register a free account today to become a member! It's completely free. Once signed in, you'll enjoy an ad-free experience and be able to participate on this site by adding your own topics and posts, as well as connect with other members through your own private inbox!

how to set up the x and y coordinates values


ciaociao

Active Member
Messages
28
Likes
0
Hi everybody,

I need to place an image above another but when I do it on photoshop using "place" command, the second image is placed few pixels away from the edges.
I was wondering if there is a way to fix and save the coordinates values X and Y before placing the image so that I have the image placed in an exact position.
the two images have the same size and same amount of pixels.

I've read posts about this subject but the answers were all about changing the values of x and y after placing the image (manually is long process).
if I change the values on the option bar the changing is related to the current file... once I open a new one the values are not saved.
I'm looking for a solution that allow me to fix and Save the coordinates before and not after placing the images.
I'm using CS6 photoshop version

thanks for the answer

Untitled-3.jpg
 
Don't know if this helps, but if you want your placed image to be in the corner just record an action:

1. place your file
2. Ctrl/Cmd+A to select all
3. V - Select move tool
4. Align to left
5. Align to top

if you want to align to corner of another layer its the same process but step "2" changes to - Ctrl+Click on the thumbnail of the layer you want align to then choose layer that you want to align in layers panel and follow steps 3-5

this will only help if you want to align to something, otherwise I can write a simple script when I get home.
 
Hi Revnart,

the way you showed above is ok when I apply the 2 images together in a single process (manually). when I do action I have some problem to replicate "place" command as the action register "place a determined image" ( when I have a folder full of file, the command "place" pick always the same image in the folder rather than picking up the following file).
I had a look at the script you've done "Folder Magic", I saw that :

desc3.putUnitDouble( idHrzn, idPxl, 0.000000 );
var idVrtc = charIDToTypeID( "Vrtc" );
var idPxl = charIDToTypeID( "#Pxl" );
desc3.putUnitDouble( idVrtc, idPxl, 0.000000 );

as I said I have no knowledge about java script but with some logic I changed the values and I got the result I was looking for.

desc3.putUnitDouble( idHrzn, idPxl, -3.000000 );
var idVrtc = charIDToTypeID( "Vrtc" );

var idPxl = charIDToTypeID( "#Pxl" );
desc3.putUnitDouble( idVrtc, idPxl, -3.000000 );

what I've done is partially fine cause is not an absolute solution (sometimes the command place the image 3 pixel away along the two axix x and y, sometimes 4 pixel along the y asix and 0 pixel along the x... is a bit annoying)

if you can... would be nice to have a script that I can apply to any action and another one inserted in the previous script "Folder Magic" you've done... if is douable

Untitled-2.jpg
 
I also tried to find on google the script for "place" command and insert in your script between

var docName = doc.name;

placeFile (B_Files, f2_scale.text);

I did many tries
but I failed :)
 
Sorry, I was a little busy. I will look into this today :) As I guess your files has different dimensions? If so, I will try to update the FolderMagic script to add function of choosing "anchor" for placing.
 
Sorry, I was a little busy. I will look into this today :) As I guess your files has different dimensions? If so, I will try to update the FolderMagic script to add function of choosing "anchor" for placing.


when you say "add function of choosing anchor for placing" you mean that will open a window asking me what point I want to anchor to? everytime?
cause I have hundreds of images I would prefer a function that set the anchor on the top left corner of the first (main) image (from folder A) (without interruptions)

the images/files have the same size (same amount of pixels)

thank you mate :)
 
Sorry, I was a little busy. I will look into this today :) As I guess your files has different dimensions? If so, I will try to update the FolderMagic script to add function of choosing "anchor" for placing.


HI again revnart,

cause I need the exact overlapping...
in case the images overlapped differs each other of few pixels...
I've seen a function called "conform" wich allow to overlap the second image, on top of the first one, by enlarging and anchoring the second one to all 4 corners
in this way the script would be perfect and always valid
same process for the third image

thank you mate :)
 
I'm working on it.. have some problems but will be ready this weekend I hope, because I'm making it in free time :)
can you post or PM me example psd with result you have and result you want? Because maybe I will find some faster way ;)
 
I'm working on it.. have some problems but will be ready this weekend I hope, because I'm making it in free time :)
can you post or PM me example psd with result you have and result you want? Because maybe I will find some faster way ;)

Hi revnart,

I here post some screenshots... hope I did it clear.
1) I open background image (from folder A)
2) I place text (rasterized from folder B)
3) I place frame (from folder C)

depending on size and position of the first image (a- background) the "place" command place the second and third image in different positions of the screen... when I do batch... as I said, the images are placed few pixels away. that's why I'm looking for an absolute references points (I mean the 4 corners and releted values) to which I can anchor each images to.

on the picture number 6 I show a feature, that I recently found out, which allow me to conform the overlapped images (b and c)

from variables, under "method" there are the 4 options :
fit
fill
as is
conform

is there a chance to put the "method" button on your Folder Magic?
as you did with scale/opacity and blending mode options?

1.jpg

2.jpg

3.jpg

4.jpg

5.jpg

6.jpg
 
I'm working on it.. have some problems but will be ready this weekend I hope, because I'm making it in free time :)
can you post or PM me example psd with result you have and result you want? Because maybe I will find some faster way ;)

what you mean with PM? sending an email? how?
 
That post is enough, I've almost everything ready with adding this options to script, but have some errors with other functions I'm adding right now, thats why I'm not posting any updates.
But if you want you can try this script (paste in notepad and save as jsx file:
JavaScript:
    var maintainAspectRatio = false;
    if(app.documents.length>0){ 
        app.activeDocument.suspendHistory ('Fill Layer on Canvas', 'FillLayerOnCanvas('+maintainAspectRatio+')'); 
    } 
    function FillLayerOnCanvas( keepAspect ){
        var doc = app.activeDocument; 
        var layer = doc.activeLayer; 
        
        var defaultRulerUnits = app.preferences.rulerUnits; 
        app.preferences.rulerUnits = Units.PIXELS; 
          
        var width = doc.width.as('px'); 
        var height =doc.height.as('px'); 
        var bounds = app.activeDocument.activeLayer.bounds; 
        var layerWidth = bounds[2].as('px')-bounds[0].as('px'); 
        var layerHeight = bounds[3].as('px')-bounds[1].as('px'); 
              
        layer.translate(new UnitValue(0-layer.bounds[0].as('px'),'px'), new UnitValue(0-layer.bounds[1].as('px'),'px')); 
        if( !keepAspect ){ 
            layer.resize( (width/layerWidth)*100,(height/layerHeight)*100,AnchorPosition.TOPLEFT); 
        }else{ 
            var layerRatio = layerWidth / layerHeight; 
            var newWidth = width; 
            var newHeight = ((1.0 * width) / layerRatio); 
            if (newHeight >= height) { 
                newWidth = layerRatio * height; 
                newHeight = height; 
            } 
            var resizePercent = newWidth/layerWidth*100; 
            app.activeDocument.activeLayer.resize(resizePercent,resizePercent,AnchorPosition.TOPLEFT); 
        } 
        app.preferences.rulerUnits = defaultRulerUnits; 
    }
Tell me if this is what you need ;)
 
That post is enough, I've almost everything ready with adding this options to script, but have some errors with other functions I'm adding right now, thats why I'm not posting any updates.
But if you want you can try this script (paste in notepad and save as jsx file:
JavaScript:
    var maintainAspectRatio = false;
    if(app.documents.length>0){
        app.activeDocument.suspendHistory ('Fill Layer on Canvas', 'FillLayerOnCanvas('+maintainAspectRatio+')');
    }
    function FillLayerOnCanvas( keepAspect ){
        var doc = app.activeDocument;
        var layer = doc.activeLayer;
      
        var defaultRulerUnits = app.preferences.rulerUnits;
        app.preferences.rulerUnits = Units.PIXELS;
        
        var width = doc.width.as('px');
        var height =doc.height.as('px');
        var bounds = app.activeDocument.activeLayer.bounds;
        var layerWidth = bounds[2].as('px')-bounds[0].as('px');
        var layerHeight = bounds[3].as('px')-bounds[1].as('px');
            
        layer.translate(new UnitValue(0-layer.bounds[0].as('px'),'px'), new UnitValue(0-layer.bounds[1].as('px'),'px'));
        if( !keepAspect ){
            layer.resize( (width/layerWidth)*100,(height/layerHeight)*100,AnchorPosition.TOPLEFT);
        }else{
            var layerRatio = layerWidth / layerHeight;
            var newWidth = width;
            var newHeight = ((1.0 * width) / layerRatio);
            if (newHeight >= height) {
                newWidth = layerRatio * height;
                newHeight = height;
            }
            var resizePercent = newWidth/layerWidth*100;
            app.activeDocument.activeLayer.resize(resizePercent,resizePercent,AnchorPosition.TOPLEFT);
        }
        app.preferences.rulerUnits = defaultRulerUnits;
    }
Tell me if this is what you need ;)
That post is enough, I've almost everything ready with adding this options to script, but have some errors with other functions I'm adding right now, thats why I'm not posting any updates.
But if you want you can try this script (paste in notepad and save as jsx file:
JavaScript:
    var maintainAspectRatio = false;
    if(app.documents.length>0){
        app.activeDocument.suspendHistory ('Fill Layer on Canvas', 'FillLayerOnCanvas('+maintainAspectRatio+')');
    }
    function FillLayerOnCanvas( keepAspect ){
        var doc = app.activeDocument;
        var layer = doc.activeLayer;
       
        var defaultRulerUnits = app.preferences.rulerUnits;
        app.preferences.rulerUnits = Units.PIXELS;
         
        var width = doc.width.as('px');
        var height =doc.height.as('px');
        var bounds = app.activeDocument.activeLayer.bounds;
        var layerWidth = bounds[2].as('px')-bounds[0].as('px');
        var layerHeight = bounds[3].as('px')-bounds[1].as('px');
             
        layer.translate(new UnitValue(0-layer.bounds[0].as('px'),'px'), new UnitValue(0-layer.bounds[1].as('px'),'px'));
        if( !keepAspect ){
            layer.resize( (width/layerWidth)*100,(height/layerHeight)*100,AnchorPosition.TOPLEFT);
        }else{
            var layerRatio = layerWidth / layerHeight;
            var newWidth = width;
            var newHeight = ((1.0 * width) / layerRatio);
            if (newHeight >= height) {
                newWidth = layerRatio * height;
                newHeight = height;
            }
            var resizePercent = newWidth/layerWidth*100;
            app.activeDocument.activeLayer.resize(resizePercent,resizePercent,AnchorPosition.TOPLEFT);
        }
        app.preferences.rulerUnits = defaultRulerUnits;
    }
Tell me if this is what you need ;)


Hi Revnart,

I just wanted to let you know that
I tried your script, it works good when the two files are both Jpeg. but the layer on top has to be PNG. on the attached files I show you what happens

the image 1 is what I get after placement (using command "place")
the image 2 is what I get after using your script
the image 3 is the result I need to get

thanks for your help... :)

1.jpg

2.jpg

3.jpg
 
ahh simple :) Its the same script :) just change first line:
JavaScript:
var maintainAspectRatio = false;
to
JavaScript:
var maintainAspectRatio = true;

and it should do the trick :)


EDIT: also you can try using not finished "Folder Magic" ;) not all options are working.. (placing by pixels is not ready yet, and some validations must be corrected but should work anyway ;)
link: https://adobe.ly/2PDixUK
Zrzut ekranu 2018-11-05 o 08.31.16.png
 
Last edited:

Back
Top