1

I want to display A.png and B.png together, A left / B right or A top / B bottom.
I can of course

preview A.png
preview B.png

separately, then resize and move the two windows next to each other, but that's a pain if you do it a lot. Can it be scripted ?
If not, is there an opensource preview-like that can display side-by-side ?

(I have 10.8.3 . if-preview-app-in-os-x-is-not-applescriptable-why-does-this-work on SO has a comment "Preview does have an AppleScript dictionary by default in 10.9 but not in earlier versions of OS X." )

1

Open the two files with Preview, then run the following to position the windows:

tell application "Preview"
    activate
    set the bounds of the first window to {0, 0, 700, 1000}
    set the bounds of the second window to {700, 0, 1400, 1000}
end tell

Customise the coordinates as you wish depending on monitor resolution.
Syntax: {x1, y2, x1, y2}

Enable AppleScript in Preview in OS X ≤10.8 by quitting Preview and running:

defaults write com.apple.Preview NSAppleScriptEnabled -bool true
0

I would do this in Automator as a Service. Using a Open Images in Preview Action and a Run Applescript Action.

So I could select the wo files and run the service on them.

enter image description here

The Applescript code should get the Size of the screen and set the bound of the windows accordingly.

set bnds to ""
tell application "Finder" to set bnds to (get bounds of window of desktop)

set FullWinWidth to (item 3 of bnds)
set halfWinWidth to (item 3 of bnds) / 2
set winHeight to (item 4 of bnds)

tell application "Preview"
    if (count of windows) > 1 then
        activate
        try
            set the bounds of the first window to {0, 0, halfWinWidth, winHeight}
            set the bounds of the second window to {halfWinWidth, 0, FullWinWidth, winHeight}
        end try
    end if
end tell

As grgarside points out you can run

defaults write com.apple.Preview NSAppleScriptEnabled -bool true

to make Preview.app scriptable for something like these simple commands.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .