Skip to main content
Inspiring
February 5, 2025
Answered

Pan to selection script

  • February 5, 2025
  • 3 replies
  • 650 views

Just want to check with fellow scripters than panning (as in using the hand tool) to move around a zoomed in large image is NOT possible with scripting? 

 

I want to zoom in on a large image and then be able to pan to a selection  - but I don't think there is anything that can help me on this one. Even the navigator doesn't highlight selections.

 

So go from :

 

to 

Using a zoomed in version of the Mona Lisa an an example

 

Correct answer c.pfaffenbichler

The code in the linked thread should preset a dialog for numeric entry but you should be able to use other input (like the active layer’s bounds/center). 

3 replies

c.pfaffenbichler
Community Expert
c.pfaffenbichlerCommunity ExpertCorrect answer
Community Expert
February 5, 2025

The code in the linked thread should preset a dialog for numeric entry but you should be able to use other input (like the active layer’s bounds/center). 

Inspiring
February 5, 2025

Oooh! Things. Just. Got. Interesting.

Stephen Marsh
Community Expert
Community Expert
February 5, 2025

@Ghoul Fool 

 

So you are already viewing one area of the image, say the upper left at a given zoom level, and there is a selection elsewhere in the image that you wish to zoom to?

 

If so, this can be hacked by making a new layer with content, such as filling the selection or creating a fill layer with the selection active and then View > Fit Layer(s) on Screen:

 

app.runMenuItem(stringIDToTypeID('fitLayersOnScreen'));

 

You could then add a zoom out as required:

 

app.runMenuItem(stringIDToTypeID('zoomOut'));

 

And delete the new active layer as it has served its purpose.

Inspiring
February 5, 2025

Stephen, that's simple and elegant!

...but I'm trying to avoid any zooming/changing magnification levels.

Stephen Marsh
Community Expert
Community Expert
February 5, 2025
quote

Stephen, that's simple and elegant!

...but I'm trying to avoid any zooming/changing magnification levels.


By @Ghoul Fool


Hah, I'd forgotten about that discussion!