39

I am fairly new with a Mac (Mac from work), and get more and more disappointed. Now I am blocked again, because I did not find an EASY way to open an image from the command line...

Here is how it works in Linux (simple, no installation required):

eog test.jpg

How to achieve the similar thing on a Mac?

3
  • 2
    open test.jpg or any executable e.g. install eog - however the issue is what do you want the command line to do after opening
    – mmmmmm
    Commented Sep 26, 2017 at 19:27
  • Oh open works! I thought I tried this. Ok, problem solved. Thanks
    – Alex
    Commented Sep 26, 2017 at 19:28
  • 1
    If one of the answers below meets your needs, you should accept it. Commented Jul 17, 2019 at 14:28

2 Answers 2

45

open test.jpg will open the image in the default application for JPEG files (on most Macs this will be Preview) and open -a Pixelmator test.jpg will open in the app Pixelmator if you have it installed. Obviously Pixelmator can be replaced with any application that can open the file.

The open command is quite powerful, it allows for opening files, directories and even URLs. I suggest you read the man page.

2
  • open -a Photos test.jpg will import the image test.jpg into Photos which is a lovely shortcut to know...
    – drewk
    Commented Sep 17, 2019 at 22:17
  • Running with wildcard in dir of interest - e.g., open *.jpg - opened Preview (default app in my case) with matches tiled in sidepane. Very convenient. Commented Oct 20, 2020 at 4:53
14

If you only want to preview the file, I recommend to use Quicklook.

qlmanage -p filename.jpg

This will launch a Quick Look window with whatever file is specified as ‘filename.jpg’, the file type can be anything that Quick Look is compatible with (which seems to be just about everything).

Source: OS X Daily

You must log in to answer this question.

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