Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
0

Enter a specific coordinate in Photoshop

Community Beginner ,
May 27, 2022 May 27, 2022

Copy link to clipboard

Copied

Hello everyone,

is it possible, in PhotoShop 23, to jump at a specific x/y coordinate entering the values in numeric form?

I work with big images and sometime I've to edit pixels at specific coordinates, it take me a lot of time to find the exact location by "navigating" with the mouse. It would be a great help for me to digit the coordinate and move the current view, or similar, to the exact location.

Thanks for your help.

Regards,

DaX

TOPICS
Actions and scripting , Windows

Views

861
Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 2 Correct answers

Community Expert , May 28, 2022 May 28, 2022

 

Some code posted by @r-bin and Mike Hale could also be combined for this task. 

I didn’t test extensively, though … 

// move the center of the window to a position;
// 2022, use it at your own risk;
if (app.documents.length > 0) {
// the dialog;
var dlg = new Window("dialog", "set window position to center", [500,300,840,450]);	
// horizontalPos;
dlg.horizontalPos = dlg.add('panel', [15,15,165,70], 'horizontal');
dlg.horizontalPos.number = dlg.horizontalPos.add('edittext', [12,12,100,32], "0",
...

Votes

Translate
Community Expert , May 30, 2022 May 30, 2022

@Dadeur â€“ Have you recorded an Action before? If not, I can upload one for you to load...

 

Edit: Here is the link:

https://shared-assets.adobe.com/link/0a2f401e-2641-4fe0-4096-06419f1a5660

transform.pngexpand image

 

The script from @c.pfaffenbichler can be saved and installed with these instructions:

 

  1. Copy the code text to the clipboard
  2. Open a new blank file in a plain-text editor (not in a word processor)
  3. Paste the code in
  4. Save the text file as .txt
  5. Rename the file extension from .txt to .jsx
  6. Install or browse to t
...

Votes

Translate
Community Expert ,
May 27, 2022 May 27, 2022

Copy link to clipboard

Copied

There may be better ways, but my first thought was an action:

 

atn.pngexpand image

 

1. Create a small, temp shape layer (i.e. zero X & Y position, 100px width/height)

 

2. Transform the shape to a new X & Y location say +1px using free transform – click the modal control to make this interactive so that it can be changed as required by entering new transform X & Y coordinates, anchor point etc.

 

3. Insert the fit layer on screen menu item command (possibly adding zoom out one or more times)

 

4. Delete the temp shape layer

 

Yes, it works!

 

P.S. What about the Navigator panel (yes, it is visual, not numerical, so perhaps not great for you)?

 

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 28, 2022 May 28, 2022

Copy link to clipboard

Copied

Good one! 

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 28, 2022 May 28, 2022

Copy link to clipboard

Copied

 

Some code posted by @r-bin and Mike Hale could also be combined for this task. 

I didn’t test extensively, though … 

// move the center of the window to a position;
// 2022, use it at your own risk;
if (app.documents.length > 0) {
// the dialog;
var dlg = new Window("dialog", "set window position to center", [500,300,840,450]);	
// horizontalPos;
dlg.horizontalPos = dlg.add('panel', [15,15,165,70], 'horizontal');
dlg.horizontalPos.number = dlg.horizontalPos.add('edittext', [12,12,100,32], "0", {multiline:false});
dlg.horizontalPos.number.active = true;
// verticalPos;
dlg.verticalPos = dlg.add('panel', [175,15,325,70], 'vertical');
dlg.verticalPos.number = dlg.verticalPos.add('edittext', [12,12,100,32], "0", {multiline:false});
// buttons for ok, and cancel;
dlg.buttons = dlg.add('panel', [15,80,325,130], '');
dlg.buttons.buildBtn = dlg.buttons.add('button', [13,13,145,33], 'OK', {name:'ok'});
dlg.buttons.cancelBtn = dlg.buttons.add('button', [155,13,290,33], 'Cancel', {name:'cancel'});
// show the dialog;
dlg.center();
var myReturn = dlg.show ();
// get the values and proceed;
if (myReturn == 1) {
var theX = dlg.horizontalPos.number.text;
var theY = dlg.verticalPos.number.text;
// get window values;
var r = new ActionReference();
r.putProperty(stringIDToTypeID("property"), stringIDToTypeID("viewInfo"));    
r.putEnumerated(charIDToTypeID("Dcmn"), charIDToTypeID("Ordn"), charIDToTypeID("Trgt"));    
var bounds = executeActionGet(r).getObjectValue(stringIDToTypeID("viewInfo")).getObjectValue(stringIDToTypeID("activeView")).getObjectValue(stringIDToTypeID("globalBounds"));
var theLeft = bounds.getUnitDoubleValue(stringIDToTypeID("left"));
var theTop = bounds.getUnitDoubleValue(stringIDToTypeID("top"));
var theRight = bounds.getUnitDoubleValue(stringIDToTypeID("right"));
var theBottom = bounds.getUnitDoubleValue(stringIDToTypeID("bottom"));
var windowW = theRight - theLeft -16;
var windowH = theBottom - theTop - 16;
// get zoom;
var theZoom = getActiveDocumentZoom();
// set position:
set_doc_position(theX*(-1)*theZoom/100+windowW/2, theY*(-1)*theZoom/100+windowH/2);
}
};
////////////////////////////////////
//filter for checking if entry is numeric, whole and positive, thanks to xbytor;
wholePosNumberKeystrokeFilter = function() {
this.text = this.text.replace(",", "");
this.text = this.text.replace(".", "");
//	this.text = this.text.replace("-", "");
if (this.text.match(/[^\-\.\d]/)) {
    this.text = this.text.replace(/[^\-\.\d]/g, '');
    };
if (Number(this.text) <= 0) {this.text = 1}
};
//  by r-bin;
function set_doc_position(x, y)  
{  
try {  
    var r = new ActionReference();    
    r.putProperty(stringIDToTypeID("property"), stringIDToTypeID("viewInfo"));    
    r.putEnumerated(stringIDToTypeID("document"), stringIDToTypeID("ordinal"), stringIDToTypeID("targetEnum"));    
    var bounds = executeActionGet(r).getObjectValue(stringIDToTypeID("viewInfo")).getObjectValue(stringIDToTypeID("activeView")).getObjectValue(stringIDToTypeID("globalBounds"));          
    var b = new Array();
    b[0] = bounds.getUnitDoubleValue(stringIDToTypeID("left"));          
    b[1] = bounds.getUnitDoubleValue(stringIDToTypeID("top"));  
    b[2] = bounds.getUnitDoubleValue(stringIDToTypeID("right"));  
    b[3] = bounds.getUnitDoubleValue(stringIDToTypeID("bottom"));  

    var dx = 8; // what is it?  
    var dy = 8; // what is it?  

    x = (b[2]-b[0])/2 - x - dx;  
    y = (b[3]-b[1])/2 - y - dy;  

    var d = new ActionDescriptor();    
    var r = new ActionReference();    
    r.putProperty(stringIDToTypeID("property"), stringIDToTypeID("center"));    
    r.putEnumerated(stringIDToTypeID("document"), stringIDToTypeID("ordinal"), stringIDToTypeID("targetEnum"));    
    d.putReference(stringIDToTypeID("null"), r);    

    var d1 = new ActionDescriptor();    

    d1.putUnitDouble(stringIDToTypeID("horizontal"), stringIDToTypeID("distanceUnit"), x);  
    d1.putUnitDouble(stringIDToTypeID("vertical"),   stringIDToTypeID("distanceUnit"), y);  

    d.putObject(stringIDToTypeID("to"), stringIDToTypeID("center"), d1);    
    executeAction(stringIDToTypeID("set"), d, DialogModes.NO);    
    }  
catch (e) { throw(e); }  
};
// by mike hale;
function getActiveDocumentZoom(){
   var ref;
   ref = new ActionReference();
   ref.putProperty( charIDToTypeID( "Prpr" ),charIDToTypeID('Zm  '));
   ref.putEnumerated(charIDToTypeID('Dcmn'), charIDToTypeID( "Ordn" ), charIDToTypeID( "Trgt" ) );
   return (executeActionGet(ref).getUnitDoubleValue (charIDToTypeID('Zm  ')))*100;
};

 

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
May 29, 2022 May 29, 2022

Copy link to clipboard

Copied

wow... since I'm not a PS "power user" your kind replyes are a bit obscure to me.

I believed there was a simplier way to input a coordinate, like in a CAD  software.

Anyway, I'll use some tutorial in order to implement what you suggest.

Thanks.

DaX

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 30, 2022 May 30, 2022

Copy link to clipboard

Copied

@Dadeur â€“ Have you recorded an Action before? If not, I can upload one for you to load...

 

Edit: Here is the link:

https://shared-assets.adobe.com/link/0a2f401e-2641-4fe0-4096-06419f1a5660

transform.pngexpand image

 

The script from @c.pfaffenbichler can be saved and installed with these instructions:

 

  1. Copy the code text to the clipboard
  2. Open a new blank file in a plain-text editor (not in a word processor)
  3. Paste the code in
  4. Save the text file as .txt
  5. Rename the file extension from .txt to .jsx
  6. Install or browse to the .jsx file to run (see below)

https://prepression.blogspot.com/2017/11/downloading-and-installing-adobe-scripts.html#Photoshop

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 30, 2022 May 30, 2022

Copy link to clipboard

Copied

And if the Script should do what you want you could assign it a shortcut (Edit > Keyboard Shortcuts). 

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
May 30, 2022 May 30, 2022

Copy link to clipboard

Copied

LATEST

Thanks a lot guys!
The script c.pfaffenbichler provvided seems to works, and I managed to install it thanks to Stephen_A_Marsh tips

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines