Remote Gallery

Remote Gallery is an application for Android devices which connects to a SSH server where your pictures are available and downloads the images to your device.

In order to save bandwidth and speed up the download, Remote Gallery optionally reduces the size of the images on the server prior to being sent. The images are cached locally on the device and are made available to other apps, such as the standard Android Gallery app.

This is open source software. If you’d like to contribute, or simply browse the code, please feel free to do so on the project’s website: https://github.com/cachapa/RemoteGallery

Remote Gallery uses a SSH client binary compiled directly from the official Dropbear source.

Configuration instructions

Remote Gallery requires that the following software is installed on your server:

  • SSH daemon (server)
  • dropbearkey (private key generator)
  • ImageMagick (to downsample the image files prior to sending)

Debian Linux / Ubuntu / other APT-based distributions

Simply install the openssh-server, dropbear and imagemagick packages. From a terminal:

apt-get install openssh-server dropbear imagemagick

Red Hat / Fedora / YUM-based distributions

I don’t have access to a YUM-based distro, but the packages should be easy to find using the package manager.

FreeBSD / OpenBSD / other Unix

How were you able to configure and run a *BSD server without knowing how to install sshd and imagemagick?

Gentoo Linux / Other Linux

See above.

MacOS

Missing instructions since I don’t have access to a Mac.

However, since MacOS is Unix under the hood, all packages should be readily available.

Windows

I’m pretty sure that all of the required software is available for Windows, but the installation is left as an exercise to the reader.

Configuration

Remote Gallery requires a dropbear private key for passwordless login. If you already have a private key generated using ssh-keygen, you can convert it to the dropbear format with the following command:

/usr/lib/dropbear/dropbearconvert openssh dropbear ~/.ssh/id_dsa dss_key

Otherwise, a new key can be generated on a terminal with the command:

dropbearkey -t dss -f dss_key

The output will be something like

Public key portion is:
ssh-dss AAAAB3NzaC1kc3MAAACBAO54x8/XT0unnG1GUKmRi0Qy4a3kW54nBOzop
EXstekcUHxnVOBrBausXadH16IkfHGxpfzZKUuk/GbURG1C3eb+V2wdp/31u6aws1
n86AvimQw1Hupq0gwNE8YrtxT7HMFTtOXadgh26vnQYyiEgZ7pnAxJuLXBlp60AtX
LTmt5AAAAFQDIKaAP0LHU3whwxt4AHb53xYq4RQAAAIA+uW4u5pQ1lZlJzVKOVnNA
afKLGTz5KLeuInYflGqr8IVkcQ9UFyQ3OoLSu6S/OVCnqIVIZpF7aWOXCxMTLWkE3
EqmNnIIW0y8WI1BDsM+Yf3Mj3BNVyK+/aEVehw8qyj1zeUJKhVcLo/3hbEQIlLWi8
B8f2+ZW8M0GyhcCXr8ewAAAIBwRX63NTnBf4eFqVzIW86peZFzbIifihwnjXWagLC
8KQGvn0GIrWX7Gpa9RWVTRlk5QrDyTpKxgIRAcnx24cKp4rnlWuLsYU6iIYdblEBI
DQe7y9PUquFszh20MGMgRqdAb6IGuT11qgt7mbKu4H66+NeKORBQhA9Mt60OdcMTl
Q== user@server
Fingerprint: md5 30:f1:a4:9e:8e:17:a1:6e:09:78:d9:6f:42:c6:8a:88

Copy the line that begins with “ssh-dss” and ends with user@server into a text file and drop it in your server, in the ~/.ssh/authorized_keys

Copy the dss_key file into your Android device. Please note that this is your private key, and it should be kept safe. Anyone who has access to this key will be able to login into your server.

Finally, make sure that ImageMagick is correctly installed:

convert -version

Should return something like:

Version: ImageMagick 6.5.7-8 2010-12-02 Q16 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2009 ImageMagick Studio LLC
Features: OpenMP

Finally, configure your server in Remote Gallery in your Android device and test it out. Please note that if you want to access your server from outside your private network, you may need to open the SSH port in your router (typically port 22).

If you have a dynamic IP address, you might also find it useful to configure a dynamic DNS service, such as the free ones offered by DynDns.com (no affiliation, just a happy customer).

32 thoughts on “Remote Gallery”

  1. Hi, I kind a like they idea of this app! Unfortunately, I could not get it to work…
    When I tap the server I’ve defined the spinner just keeps on spinning forever and nothing seems to happen.
    I’ve monitored traffic on the server end but I’m not seeing anything on port 22.
    I can connect to my server using ConnectBot, so this not a simple connectivity issue.

    Any clue what is wrong?
    Thanks, hope you can help me.

  2. Teun,

    could you try updating the app on the Android Market? I just added the ability to test the connection, it might shed some light on what’s happening.

    Other than that I have no idea what the problem could be. It seems that your connection is stalling on something. Did you use a Dropbear private key?
    Please note that ConnectBot uses OpenSSH private keys, which are different from the dropbear ones.
    Please refer to the text above (the final section: Configuration) on how to create or convert an existing private key to the Dropbear format.

  3. Thanks for the update.I’ve tested the connection but just get black screen.
    The key I’m using is indeed a dropbear key,setup according to the instructions above.
    I just mentioned connectBot because I used it to check port 22 connectivity.

  4. Sorry for the black screen. That was because the test was running on the UI thread, and it was blocking the activity until it was finished.

    Could you update again? I’ve moved the test to a separate thread.

    I suspect that the problem you’re having is that your server is expecting some kind of interaction, such as asking for a password, or asking for some kind of confirmation. This is blocking the connection, which is expected to run fully automatically.

    Hopefully you’ll see what your server is asking for in the Connection Test, and I’ll be able to work around it.

  5. Thanks, I found the problem. I stored my key file in the “my Documents” folder. The app seems to choke on the space in the path. :)

  6. Nice app if i would be able to run. I follow all your instructions but the app returns an error regarding “a string too long” after connection. What’s wrong?

    Bye

  7. deleted and recreated the host link into app. connection ok. But…
    I have a linux server with busybox. it seems that some commands have different switches. could you please provide an external configuration file where the user can write the right command for his linux platform?

    many thanks

  8. I was going to ask if you’d tried long pressing your serve entry ans selected “test”.

    Editting the command may be possible. What exactly would you like to change?

  9. I would change commands to fit my shell! The busybox shell is slightly different from the ubuntu one. For example the “ps” command doesn’t accept any switch except “-w”! Could you give the path of the configuraton fi

  10. I asked to see to what extent you needed to edit the commands.
    The current command string is hardcoded into Remote Gallery, simply because I assumed that every Unix system will have ls, with the same switches.

    Since that’s wrong, I’d like to know just what switches are different in your implementation, so that I can make configuration options for those (or better yet, identify the remote server automatically).

    The command for ls is currently hardcoded to: “ls [path] –indicator-style=slash”

    If you’d like, you can look at the source for yourself:
    http://code.google.com/p/remotegallery/source/browse/trunk/src/net/cachapa/remotegallery/ssh/SshOutputReader.java

  11. great app!

    i’d like for android’s standard gallery app to pick up the cached photos (as a folder, i suppose). you mention “…and are made available to other apps, such as the standard Android Gallery app…” but it doesn’t seem to be happening for me. is there some way to trigger this?

  12. Android’s Gallery app will eventually pick up the photos, but it does take some time.
    The Gallery depends on a system service which indexes media files (at least audio and photos) and runs from time to time.
    Unfortunately, I don’t know how to trigger it to run. Some apps in the Android Market claim to be able to do it, but they didn’t do anything on my Nexus S.
    Restarting the device a waiting for a while sometimes works, but YMMV.

    I also can’t understand how Gallery sorts its albums. It seems that it’s by the file’s creation date. At least my albums aren’t organized either by folder name, or EXIF date.
    It all sucks a bit, but that’s true of Android’s Gallery app in general — it sucks a bit.

  13. thanks for the prompt reply.

    i googled for ‘android’ ‘gallery’ ‘refresh’, and someone suggested deleting the gallery app’s data and cache. sure enough, when i re-opened gallery it dutifully refreshed itself, but it is till not picking up the cached images in /sdcard/RemoteGallery/. i thought that maybe gallery only looked in /sdcard/download, /sdcard/dcim, and maybe a few other places, but the screencapture program installed puts its images in /sdcard/screenshots, and gallery has no problem picking those up.

    i will wait and see if gallery eventually picks it up…

  14. The Android Gallery ignores files inside folders which contain a file called “.nomedia”
    You should see that file inside RemoteGallery’s “Thumbnails” folders (RG creates it automatically).
    If you have such a file anywhere else than inside the thumbnails folders, then it shouldn’t be there, and you’ll have to delete it.

    Otherwise it might be that the Android Gallery is taking longer because it’s reading all the files first.
    But as I said, my experience with the media indexing is very limited, and it seems to behave quite randomly here, so don’t take my word for it :-)

  15. good to know about the .nomedia file…

    i have another problem, although minor. it doesn’t seem to affect anything, but whenever i refresh i get a toast message: “Error: /data/data/net.cachapa.remotegallery/files/ssh: Failed to open /data/.ssh/known_hosts.” it’s only an annoyance, but when the refresh updates multiple files, as when opening a new server profile, i seem to get a toast message for each file, which keeps toast open for quite a long time.

    oh yes, and i forgot to ask:

    is there some way of configuring the use of the image magic tools? it looks like they’re being resized to my device’s screen size. what about an setting to specify things like resize (ratio, or absolute), and jpeg compression factor? and the ability to download the full image on demand would be nice…

    many thanks.

  16. Regarding the toast, that should have been filtered :-)
    The ssh binary spits that warning every time it connects because I couldn’t get it to either create that file where I wanted it, nor stop it from trying to create it at all.

    For now, it’s not possible to configure the image magick command line.
    I’d love to have that in the program, but I didn’t have time to implement the preferences for it.

    If you have any experience developing for Android, and you’d like to do it yourself, Remote Gallery is open source software: http://code.google.com/p/remotegallery

  17. i haven’t taken a stab at android programming yet, but the time is approaching…

    the same forum that suggested clearing the data/cache for the gallery app, also suggested that unmounting/remounting the sdcard might work. it did for me. there’s supposed to be widget in the market that does it, but i can’t find it, i guess it’s been removed. rebooting works. so does mounting the sdcard via usb and then ejecting. i can’t unmount via settings, as i’m running link2sd. oh well. no biggie.

  18. Great program! I’m very enthused about it.

    I’ve found what I think is a bug. (and couldn’t find where to file it).

    If there is a colon in the filename of an image, it chokes.
    “Error:/mnt/sdcard/RemoteGallery/1/cache/$filename.jpg.temp (Invalid argument)”

    I suspect this is related to the ssh command that transfers the file to android.

    Thanks for the work on this project.

  19. Works nicely. You should point out, that you do not need dropbear running as ssh-server on the remote server. All you need is a key on the phone in dropbear format.

    Cheers.

  20. Just installed: wonderfull app.
    There is a slight problem though: there are escaping issues when converting images. The message on the phone says something along the lines of “bash: -c line 0: missing closing ‘ “. This is because I have directories with ‘ in their names (frequent in french). The same happens when a file contains this ‘ character (single quote).
    The Android app seems to retry endlessly when the problems occurs, leading to endless alerts on the screen (maybe it’s only queued messages that just dispolay slowly, I don’t know).

  21. @Nicolas the bug with infinite retries is fixed in development.
    As for the problem with quotation marks, thanks for the report. I’m going to add it to the bug issue repository.
    Unfortunately, I can’t dedicate much time to RG right now. The project is open source though, so if you have any experience with Android development perhaps you could volunteer some time to fix it yourself?

  22. The command to install imagemagick on Mac OS X (assuming you have ports installed) is ‘port install imagemagick’, but dropbear is not available through the ports installer, so generating a key requires using a different computer or looking up the OS X ssh key generator commands. Also note that the convert command (installed in /opt/local/bin/) may need to be symlinked to /usr/bin/ for remote gallery to find it.

    A note on ls invocation—the long-form options are particularly variable across UNIX variants, notably including OS X. The option ‘-p’ is a synonym that should be much more reliable than the current ‘–indicator-style=slash’ and I’ve verified its validity on OS X’s variant (as well as the GNU version generally seen on Linux desktops).

  23. Bug filed at github (#11), including trivial patch to fix this and the argument ordering issue seen with the BSD (including OS X) versions of ls.

  24. I’m not able to get this working, I’ve gotten it to work once before but I can’t remember how I did it.

    When I test the connection it says

    “connection okay” in green but under that it says

    “/data/data/net.cachapa.remotegallery/files/ssh: exited: string too long”

    And I can’t figure out how to get this working I’m not a noob to linux or ssh but this just doesn’t work and I know it can cause like I said I’ve gotten it to work before…

  25. Could be that your path is too deep (or the filenames are too long) and ssh doesn’t like that.

    To be honest I didn’t even know there was a limitation…

  26. I’m disabling comments here because it’s too difficult to keep track of all the different conversations.
    If you have questions or comments on RemoteGallery, please post them on the project webpage.

Comments are closed.