You are not logged in.

#1 2013-05-14 00:19:29

Profpatsch
Member
Registered: 2013-02-06
Posts: 22

imup – CLI Tool to Upload Images to Imagehosts

https://github.com/Profpatsch/imup
AUR: https://aur.archlinux.org/packages/imup/

This is a small and extendable program that takes a filename as an argument, uploads it to an imagehost and returns the link to the uploaded image to stdout.

Update: Featured on One Thing Well. Thanks to whoever posted it.

Why?

I oftentimes want to share screenshots over IRC or Jabber, yet it always took a minute to take it, go to a random filehost, upload it and copy and paste the link.
Now I’ve got this as a shortcut:

% import $SCREENSHOT.jpg && imup $SCREENSHOT.jpg | xclip -selection clipboard
Other imagehosts?

Yep, easily done.
Check out the documentation on Github on how to do it.


What else is there to do?

Go to the issue page and filter for enhancements.

If someone wants to do a PKGBUILD, I’m all for it.


0.2.0: imgur.com is available in addition to imm.io .
0.2.2: PKGBUILD works. Changelog added.
0.2.3: If no host is directly specified with -i, try with another server if the chosen one doesn’t react.

Last edited by Profpatsch (2013-11-01 17:30:09)

Offline

#2 2013-05-16 15:50:17

djszapi
Member
From: Cambridge, United Kingdom
Registered: 2009-06-14
Posts: 1,439
Website

Re: imup – CLI Tool to Upload Images to Imagehosts

Nice one!

This should go into community ASAP in my opinion as it is a must have for a CLI distribution like Arch for me. smile

I have two ideas for improvement though:

1) You could hide the import usage by calling a subprocess internally, for instance by using a dedicated option to imup.
2) You could give a lot more useful error message when your command above is copied and pasted 1:1 (i.e. $SCREENSHOT will be an empty string). The current error message is vague.
3) This is just a not here, but for double mouse click, you will get the entire screen captured without you having to select the whole screen area explicitly.
4) You could also integrate xclip as an option, and calling it a subprocess.
5) Moreover, xclip could be entirely abtracted out to make this script fully cross-platforn.
6) Taking an image uploader expiration duration. The closest or none would be picked up for the given host available.

Last edited by djszapi (2013-05-16 23:18:27)

Offline

#3 2013-05-17 21:28:43

Profpatsch
Member
Registered: 2013-02-06
Posts: 22

Re: imup – CLI Tool to Upload Images to Imagehosts

Thanks!

Your feedback is very much appreciated.

1) I thought about this. Yet, it kind of destroys the “one thing well” part. Especially since one can simply string import in front. I guess the way to go here would be a (shell) script that strings various possible usages for capturing and uploading a screenshot together. It could be called “scrimup”. wink
2) Looking into this.
3) Oh, that’s funny, I didn’t know that. I used another shortcut with

import -window root FILE

at the beginning.
4) 1)
5) Abstracted out to not be dependent on X11, or only to not be dependent on xclip?
6) I don’t understand what you mean by that. Ping to image host? A switch after a timeout?

Offline

#4 2013-05-18 05:41:01

djszapi
Member
From: Cambridge, United Kingdom
Registered: 2009-06-14
Posts: 1,439
Website

Re: imup – CLI Tool to Upload Images to Imagehosts

1) and 4): The problem is that with two different executables is that you will have two different executables and hence more maintainence. I was actually thinking of writing a qt command line application with everything necessary included into one executable. I do not think script is a good idea as it is short enough. A simple alias or shell function can do, but then again, that is more layers to the end users.

5) Cross-platform, like Qt. So you can actually use the executable even on Windows or Mac. Not sure if there is a cross-platform python solution already provided by some existing library. It is viable with Qt, at least.

6) When you upload texts to certain pastebin engines, you can select an expiration duration. That is the intended duration after which you would like to get your content invalidated on the server, i.e. not available anymore. Of course, this needs server side support. Still, the user could supply a value, and the application returns a warning if the server does not support that. That is just for an example.

Last edited by djszapi (2013-05-18 05:46:58)

Offline

#5 2013-05-18 17:24:28

Profpatsch
Member
Registered: 2013-02-06
Posts: 22

Re: imup – CLI Tool to Upload Images to Imagehosts

1) and 4) I decided on not adding something like that to imup, since it would introduce the dependencies you are speaking about. The current version has no dependencies at all (except python stdlib) and is completely cross-platform. Instead I am going to write a shell script that strings the screenshot stuff together in a meaningful way. As for maintenance, there is going to be none, since the script isn’t going to change when imup changes (except maybe for major new options that can be used).

2) This is exactly what happens when you give the program a Postscript file. import is given the filename ".jpg" and it defaults to postscript, which can’t be uploaded by imup. And a Postcript is no image. wink
I’m going to add calling xdg-mime, since Python’s internal mimetypes module can only use filenames and doesn’t look at the actual files. And it’s going to tell you what kind of filename you have given it.
Edit: DONE.

5) It’s fully cross-platform, runs on every platform that supports Python 2.x (I’d have used Py3k, but the library I use for encoding the http post is only 2.x. Should port it sometime.

6) That’s a cool idea. I guess some hosts support that. Does anyone know which ones do?

Last edited by Profpatsch (2013-05-18 21:17:09)

Offline

#6 2013-05-19 11:53:54

djszapi
Member
From: Cambridge, United Kingdom
Registered: 2009-06-14
Posts: 1,439
Website

Re: imup – CLI Tool to Upload Images to Imagehosts

1) and 4): Those could be optional which means it would not bring any hard dependency in. Adding additional layers for such minor things is too much hassle IMO. There could be an option for those.

5) My feature request is not cross-platform as long as xclip is not. As for Qt, you could capture the screen content and then upload with QtNetwork. That could become cross-platform, but I am not sure if python provides anything abstracted for "xclip" and "import" like functionality.

6) I do not, unfortunately. Perhaps, dropbox support could be added, and that I could remove later on my own when not needed anymore.

Offline

#7 2013-05-19 16:31:59

Profpatsch
Member
Registered: 2013-02-06
Posts: 22

Re: imup – CLI Tool to Upload Images to Imagehosts

1) Well, it’s the first idea of what can be done with the program. I guess there are hundreds of other uses for it which I haven’t considered yet. If I start adding everything that comes up but is really just a call to string some pipes together it’s going to be lots of work that other already did.

5) Yep, it’s not. I runs on exactly every system that uses an X Server. Which is >99% of Linux PCs atm. I’m sure it’s not that hard to write a script for Windows, although I don’t know if there is something as simple as xclip. I’m sure there is a comparable tool on Mac.
Qt in itself is just a GUI toolkit afaik, which is not on the same level as X. I wouldn’t count it as a platform in the sense of that it needs porting stuff to. Maybe from GTK+, yes. But since we’re talking CLI here…

6) Dropbox and Owncloud should definitely be available. They are a little different from pure image hosts, though and probably need config.

Offline

#8 2013-05-23 17:45:41

djszapi
Member
From: Cambridge, United Kingdom
Registered: 2009-06-14
Posts: 1,439
Website

Re: imup – CLI Tool to Upload Images to Imagehosts

1) That means I have to create my own tool from scratch for my need to be self-contained. smile

2) Qt is not a GUI toolkit, but an application development framework. Well, X is already not pure cli anyway, so Qt would work just fine. By the way, I am also an upstream Qt developer just for the record. smile

I am not sure if GTK+ could ever be as nicely cross-platform as Qt.

Offline

#9 2013-05-24 13:43:34

Profpatsch
Member
Registered: 2013-02-06
Posts: 22

Re: imup – CLI Tool to Upload Images to Imagehosts

1) Indeed. I think this need is actually quite destructive, for it is simply not the way *nix works.

2) I didn’t know Qt could do non-GUI, too, but I still think it’s on the same level with GTK+, since that one’s based on glib. Actually I see C as a big pro, compared to C++. wink
Anyway, why would I want to introduce a horrendously big dependency with Qt?

Offline

#10 2013-05-25 09:35:36

likytau
Member
Registered: 2012-09-02
Posts: 120

Re: imup – CLI Tool to Upload Images to Imagehosts

I might see if I can add full Imgur support, as I'm really only interested in image uploading if its under my username, on Imgur.

djszapi : That's an elegant symmetry, since I'm not sure that Qt will ever be as nice as GTK smile

On the subject of an xclip-analogue for Windows, I found this SuperUser question, which indicates that there's only a builtin tool ("clip") since Vista, but there is also a third party tool you can install.
Since xclip is not installed by default on many distros either, that seems a reasonable requirement.

Last edited by likytau (2013-05-25 09:37:13)

Offline

#11 2013-05-25 22:46:43

Profpatsch
Member
Registered: 2013-02-06
Posts: 22

Re: imup – CLI Tool to Upload Images to Imagehosts

Do you think adding --username and --password (-u and -p) would make sense for a lot of hosts?
I didn’t look into this deeper, but from what I saw your http POSTs need to be a lot more complicated with auth.

Now I imagine how helpful it could be if you could for example upload pictures directly to, say, your Wordpress blog or similar. Maybe adding batch uploads would make sense. smile

Offline

#12 2013-05-26 01:56:06

likytau
Member
Registered: 2012-09-02
Posts: 120

Re: imup – CLI Tool to Upload Images to Imagehosts

Certainly there are plenty of hosts that let (or even require) you to have an account in order to upload:

* imgur
* imageshack
* photobucket

and also more sophisticated sites that expect a description and other metadata. They mostly require the usage of Mechanize to complete the image-upload process:

* flickr
* DeviantArt and its imitators (SA, FA, IB, etc.)

password is a special case, since you usually don't want to put it in the commandline. Otherwise, it might be a good idea to allow an arbitrary number of "--KEY=VALUE" arguments on the commandline preceding the image filename. This  could address the more low level needs of username, (and password -- i know some people will use it like this even if it's insecure) while also allowing for more specific settings like description and tags when the service requires it.

Batch uploads I would definitely find useful personally -- I often have small (3-8) image sets to upload.

Offline

#13 2013-05-26 14:30:07

Profpatsch
Member
Registered: 2013-02-06
Posts: 22

Re: imup – CLI Tool to Upload Images to Imagehosts

Yes, for these sites authentication should be possible.
I don’t know if I should even allow plaintext passwords, since there is the python keyring, which integrates with most keyring services.

I won’t integrate DeviantArt &al., since these platforms aren’t intended as imagehost and would get destroyed if people were to post non-annotated pictures in batch. Except, of course, there is a good reason for doing so and/or someone opens a pull request. wink

If I were to include something like arbitrary headers or key/value command line options there wouldn’t be any reason to not use curl for the job directly. wink
But for some services it might make sense to allow additional arguments. We’ll see.

Offline

#14 2013-05-27 09:15:53

Svenstaro
Developer
From: Germany
Registered: 2008-11-19
Posts: 365

Re: imup – CLI Tool to Upload Images to Imagehosts

If you guys make an AUR package for this, I might pull it into [community].

Offline

#15 2013-05-27 09:37:14

likytau
Member
Registered: 2012-09-02
Posts: 120

Re: imup – CLI Tool to Upload Images to Imagehosts

Profpatsch wrote:

Yes, for these sites authentication should be possible.
I don’t know if I should even allow plaintext passwords, since there is the python keyring, which integrates with most keyring services.

Fair point.

I won’t integrate DeviantArt &al., since these platforms aren’t intended as imagehost and would get destroyed if people were to post non-annotated pictures in batch. Except, of course, there is a good reason for doing so and/or someone opens a pull request. wink

Yeah, I wasn't expecting integration, just 'the features that would make it practical for *someone* to implement it'

My personal reasons are:

* The interface is annoying, particularly if you always want a custom thumbnail, or in the (extremely common) case that you tend to submit to only a few possible categories. DMenu is better for category selection than DA is ever likely to be.
* I prefer to pre-write titles, descriptions, and tags in a proper text editor rather than use the limited one in the web browser
* Avoid that tendency for time to quickly disappear when I'm on the web, by just not going on the web.

If I were to include something like arbitrary headers or key/value command line options there wouldn’t be any reason to not use curl for the job directly. wink

Actually no, sites like DA,FA,SA,IB have a multi-stage submission process, so it's probably not true that you can just curl a url and all will be fine. That's why I mentioned Mechanize. The point is just to be able to tell the site-handler module exactly how you want the thing uploaded (what description, category, tags, etc.). I don't see any use for passing arbitrary k/v pairs / headers to the *server*.

Last edited by likytau (2013-05-27 09:38:59)

Offline

#16 2013-07-23 15:57:06

Profpatsch
Member
Registered: 2013-02-06
Posts: 22

Re: imup – CLI Tool to Upload Images to Imagehosts

@Svenstaro I did the PKGBUILD, so if the offer is still standing…
You should check it for quality, though, since I haven’t done this before and it’s quite complicated.

As for a little update, things that need to be done are now Issues and there is a 1.0 milestone. Slow progress, but so much other stuff to do. -.-

Last edited by Profpatsch (2013-07-23 15:58:55)

Offline

#17 2013-07-24 04:51:59

orschiro
Member
Registered: 2009-06-04
Posts: 2,136
Website

Re: imup – CLI Tool to Upload Images to Imagehosts

Hi Profpatsch,

Have you thought of including scrot in your application?

Instead of just uploading an already existing picture it would be great to actually take a screenshot (entire screen or selection) prior to uploading it to a file host.

What do you think?

Offline

#18 2013-07-24 09:00:37

Profpatsch
Member
Registered: 2013-02-06
Posts: 22

Re: imup – CLI Tool to Upload Images to Imagehosts

scrot screenshot.jpg && imup screenshot.jpg

Here you go. Done.

Offline

#19 2013-08-15 20:35:01

Profpatsch
Member
Registered: 2013-02-06
Posts: 22

Re: imup – CLI Tool to Upload Images to Imagehosts

I finally pulled myself together and uploaded the package to AUR—wasn’t too hard, was it?

You can find it at https://aur.archlinux.org/packages/imup/

Last edited by Profpatsch (2013-08-15 20:35:15)

Offline

#20 2013-08-15 23:30:00

Profpatsch
Member
Registered: 2013-02-06
Posts: 22

Re: imup – CLI Tool to Upload Images to Imagehosts

Update: If you like this little program, go vote for it on AUR. We need 10 votes for it to go into Community.

Offline

#21 2013-09-14 21:55:24

bart_vv
Member
From: Poland
Registered: 2011-04-12
Posts: 37

Re: imup – CLI Tool to Upload Images to Imagehosts

That's a damn useful program! You've my vote.

Offline

#22 2013-09-16 18:07:24

Profpatsch
Member
Registered: 2013-02-06
Posts: 22

Re: imup – CLI Tool to Upload Images to Imagehosts

Thanks! 3 more to go. wink

I hope I find time to build in some more functionality in the near future. Kind of busy atm.

Offline

#23 2013-11-01 17:26:44

Profpatsch
Member
Registered: 2013-02-06
Posts: 22

Re: imup – CLI Tool to Upload Images to Imagehosts

I noticed that imm.io had a lot of downtime.

Now when not specifying an image host with the -i option, it will try until it finds a working host or runs out of possibilities.
Since this is useful, have a push to v0.2.3.

https://aur.archlinux.org/packages/imup/

Next up:
Implementation of authentication with https.

If you use the package, please don’t forget to vote. 2 more and it goes to community.

Last edited by Profpatsch (2013-11-01 17:28:16)

Offline

#24 2014-03-21 12:28:51

djszapi
Member
From: Cambridge, United Kingdom
Registered: 2009-06-14
Posts: 1,439
Website

Re: imup – CLI Tool to Upload Images to Imagehosts

I just gave the 10th vote. Go go community! ;-)

Offline

#25 2016-04-06 18:28:43

djszapi
Member
From: Cambridge, United Kingdom
Registered: 2009-06-14
Posts: 1,439
Website

Re: imup – CLI Tool to Upload Images to Imagehosts

What happened to the AUR package?

Offline

Board footer

Powered by FluxBB