How can I view pictures via ssh

28

9

I am monitoring a website and want to know if there is a way that I can view the pictures via ssh rather than loading the website each time.

mrhobbeys

Posted 2013-02-26T13:40:40.773

Reputation: 293

so you have ssh access to the server and are watching the images directory? – Frank Thomas – 2013-02-26T13:46:01.577

Yes, I setup a scritp to alert me when something new is added. Now I want to be able to view it and remove or approve via ssh. – mrhobbeys – 2013-02-26T14:04:24.763

Answers

35

You haven't said what Operating System you are connecting from. If you are using a *nix running an X server, you can use ssh X forwarding. This will enable you to run graphical applications on the remote server and have them displayed on the local machine. For example:

ssh -Y user@server
eog pictures/foo.png

Assuming the server has eog installed, this should cause the image to be opened and displayed on your screen.

For future reference, when asking questions on this site it is a good idea to specify the system you are using because the correct answer will often depend on it.

terdon

Posted 2013-02-26T13:40:40.773

Reputation: 45 216

I'm on windows with putty and xming today, so I am going to give this a try. – mrhobbeys – 2013-02-26T15:10:15.703

This works nicely. – mrhobbeys – 2013-02-26T15:20:13.293

5

if you are on OS X, using iTerm2, you can do imgcat and display the image right in the terminal.

https://www.iterm2.com/documentation-images.htmlenter image description here

Dyno Fu

Posted 2013-02-26T13:40:40.773

Reputation: 206

What if you're on osx with iterm 2 and have used ssh to get into a remote machine? – Andrew Hundt – 2017-03-21T22:20:16.547

1It will work if you have the imgcat script on the server. – Dyno Fu – 2017-03-21T22:25:17.207

3imgcat, wouldn't an image of a cat be more appropriate? – CousinCocaine – 2018-06-18T21:12:27.783

Does the server have to be OS X? What exactly should I do if my server is Ubuntu and my client is Mac? – Sridhar Sarnobat – 2019-09-03T20:30:22.727

there is no requirement on server. if you are ssh from the terminal, the server has to have imgcat. basically, imgcat convert the image to something iTerm2 can understand. – Dyno Fu – 2019-09-03T20:38:46.527

3

This is a common pain point amongst computer vision researchers. I created a tiny script (https://github.com/nicodjimenez/ImgView) which I use to serve images in a directory on a remote machine via python run.py -d path/to/image/dir/. Then I use ssh tunneling to forward a local port to the remote port on which I am running the server, and then I just view the images on my local machine by pointing my web browser to my local port, by default http://0.0.0.0:8000/. This approach is the most flexible for viewing images over ssh because you can control the appearance of the display.

nicodjimenez

Posted 2013-02-26T13:40:40.773

Reputation: 131

Looks like the repo is down, but this can also be accomplished with the built in web server python -m SimpleHTTPServer. Also if your local machine and server are on a VPN, there's no need to ssh forward. – crizCraig – 2017-05-08T01:40:56.537

With python 3: python -m http.server. Will serve al files in current folder. – fabian789 – 2019-08-05T12:05:36.737

2

tiv (or similar tools) should do in most cases. This does not require any special terminal emulators since it only prints RGB ANSI codes.

enter image description here

Also supports wildcards.

phil294

Posted 2013-02-26T13:40:40.773

Reputation: 123

1

On Linux you could redirect ssh output. With the help of an image viewer able to read from the standard input (see Is there an image viewer that takes images on STDIN? ) and the Unix Pipe |, I get:

ssh remote_host "cat /remote/path/to/image" | display

PS: this requires ImageMagick's display program on the local host. The command between quotes is executed by ssh on the remote host. Or for other image viewers (here Gnome eog image viewer):

FIFO=$(mktemp -u);
ssh remote_host "cat /remote/path/to/image" > "$FIFO";
eog  "$FIFO" && rm "$FIFO";

Alban Browaeys

Posted 2013-02-26T13:40:40.773

Reputation: 29

1

In general you may transfer the media data, e.g. images, to your local desktop or the ssh terminal itself if capable of displaying media:

  • XWindow forwarding: brings any desktop imageviewer application from the remote host to your display
  • sftp: any sftp-client transfers the media to your local desktop where you may launch an image viewer
  • ssh filesystem: a bit like sftp, but the remote filesystem is seamlessly integrated locally so local image viewers may launch
  • Or webbased: This terminal (like many others) is itself capable of displaying image data (the image data is "cat"ed !)

http://liftoffsoftware.com/Products/GateOne enter image description here

SLN

Posted 2013-02-26T13:40:40.773

Reputation: 71

0

You can add a network storage in your systemfile explorer :

Adding a server

ZettaCircl

Posted 2013-02-26T13:40:40.773

Reputation: 101

0

Visual Studio Code's SSH extension lets you view remote images in the editor. It's cross-platform and does not require a local X server.

Paul Richter

Posted 2013-02-26T13:40:40.773

Reputation: 299

0

If you have the path of the pictures you can like Frank Thomas said then you can download them and open them in a picture viewer via scp or maybe sftp if you have access. If you're using linux then do a wget on the pictures, but of course you can't open them in a shell, so downloading them is you best option if you are talking purely shell.

MDMoore313

Posted 2013-02-26T13:40:40.773

Reputation: 4 874

This wouldn't really work well only because at that point it would be easier to open a browser to see them. – mrhobbeys – 2013-02-26T14:05:45.853

Well it depends on the setup, because if the picture names have a similar path and naming convention, then it could be scripted and turned into a cronjob. – MDMoore313 – 2013-02-26T14:22:44.487

0

You can also use sshfs, if you're under Linux.

carlspring

Posted 2013-02-26T13:40:40.773

Reputation: 140

or use WinSCP if on Windows. – Frank Thomas – 2013-02-26T15:27:15.097

1@FrankThomas: Well, that wasn't what I had in mind. With sshfs you can simply mount the remote file system and it will behave as if the files are on your computer. No need to download anything... – carlspring – 2013-02-26T15:41:10.623

0

I use thunar (a file manager, also works with nautilus and probably others) to do this kind of stuff.

If you enter the address:

sftp://user@ip:port/

It will connect via ssh (optionally asking for a password/passphrase) and it will display the filesystem visually, where you can open the images with a viewer (eg. gpicview or eog, but I found eog to be slow in this case).

Paul

Posted 2013-02-26T13:40:40.773

Reputation: 113