I'm working on a program that generates an image. I can keep the image open in Preview and when the image changes, Preview refreshes it, but only when I alt-tab (sorry, command-tab) to it. I'd like to keep the image in view and have it auto-refresh without touching it. Is that possible?

(One ridiculous way I've found to do this is with a script that converts the image to a PDF file which I can keep open in Skim.app (a PDF reader) which has that ability.)

  • A program does not have a feature you want it to have, and using another application to solve your problem is a "ridiculous way"?
    – Daniel Beck
    Jan 12 '11 at 5:37
  • 3
    The conversion to PDF is what makes it an ugly solution. If Skim.app could view images (like .png) it would be a great solution.
    – dreeves
    Jan 12 '11 at 7:48

Open AppleScript Editor and enter the following:

tell application "Preview" to activate
tell application "AppleScript Editor" to activate

Replace the second application's name with the program you want to have frontmost. Save as scpt and incorporate a call to this script into your program to refresh Preview:

osascript refresh-preview.scpt

You can alternatively use Automator to create a Service that receives no input with the Run AppleScript action and the above code. Save, and assign a keyboard shortcut in System Preferences. Not exactly automatic, but easier than getting the mouse to focus Preview.

Using the program open would be another idea, although using the switch -g (don't bring to foreground) opens the file in a new preview window every time its been modified, even if it's already open. All windows get updated though, without being brought to the foreground.

  • Oh! This is perfect! It looks like open -g image.png actually does exactly what I want. It doesn't seem to open a new preview window each time. Thanks so much for the help!
    – dreeves
    Jan 12 '11 at 10:57
  • @dreeves Probably depends on the way your program handles changes to the file. I tried it with Automator and the rotate image action, and it behaved as I describe.
    – Daniel Beck
    Jan 12 '11 at 11:05

Visual Studio Code allows you to open images and will also refresh them automatically without any interaction needed.

  • Why the downvote? Quoting the asker "If Skim.app [with it's auto refresh feature] could view images (like .png) it would be a great solution". Visual Studio Code is free, unlike XEE which has already been mentioned. Aug 21 '16 at 19:26
  • This is a very helpful answer! I will try it next time I need this. I'm just worried that opening Visual Studio just to view images could be too heavyweight.
    – dreeves
    Aug 21 '16 at 20:33
  • 1
    Atom, another code editor, has the same ability with a little less interface showing. (They are very similar.)
    – Nabha
    Feb 9 '19 at 6:56

You can use XEE, it's an image preview software that includes autorefresh. (http://xee.c3.cx/)

  • If this helps anyone: this worked for me for small files, but on large (~17 mb) tiff files, it had a second of static between refreshes. I needed to it for a presentation, so it was almost but not quite the right solution.
    – Nabha
    Feb 9 '19 at 6:44

You could use applescript to give Preview focus every x seconds.

  • Can you elaborate on how to do that?
    – fixer1234
    Feb 9 '19 at 7:17
  • Activate Preview as done in Daniel Beck's answer. But with a delay command too.
    – ocodo
    Feb 9 '19 at 12:02

You can perform the task simply by appending the following alias to your shell startup scripts (bashrc (or similar))

alias prefresh='echo "tell application \"Preview\" to activate" | osascript -'

Then just invoke the alias when you need it.


Apollo One (macOS only) seems to do a good job of this, even when running full-screen and not being tabbed to.

It's a basic image viewer. All I had to do was open the correct image and it would reload as the image file changed, even at full screen on a second monitor.

It did crash on me at one point when there was very high CPU usage and I had to reload it. Just something to be aware of.

Also, if you have trouble with it switching to another image in the same folder, the thing to do is just to make sure it's the only image in the folder.

See also the Apollo One webpage (seems to be down at the moment though).


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.