simple software request (command line image uploader)

11 views
Skip to first unread message

Elliot Temple

unread,
Jul 13, 2018, 2:52:42 PM7/13/18
to FI, FIGG
Would someone create the following for me?

Tool that uploads the image on the clipboard to an ftp site i configure (give it a random filename to avoid collisions), and then puts the link on my clipboard.

Command line script or AppleScript or something that I can get onto a global hotkey. Mac compatible. Configuration by editing the ftp info into the script is fine (command line parameters are fine too).

the ftp site config will need to include the directory to save the images too. i'll make a directory just for this. sftp is fine (probably better). or if it does the upload over ssh that's fine too.


Basically it works like https://puush.me except it uploads to my own web server so the images will never go away if puush shuts down. Also for simplicity it can be a two step process: step 1, screenshot. step 2, upload. That seems good enough and probably way easier. As opposed to puush where you don't have to hit a second hotkey after taking the screenshot.


If anyone disagrees with the value of this tool, let me know. I think it'd be good because of my concern that puush could shut down and links to old images could stop working.

i am open to suggestions for a better way to do this. or if someone knows of existing software to do it, please let me know.

PS i added image support to my blog comments.

http://curi.us/2041-discussion#c10117

and btw you can post images to FI (just as plain links). ppl rarely do but it's really easy with puush: press screenshot hotkey, take screenshot, wait a few seconds, use paste hotkey.

Elliot Temple
www.elliottemple.com

Alisa Zinov'yevna Rosenbaum

unread,
Jul 14, 2018, 9:20:50 AM7/14/18
to fallibl...@googlegroups.com, FI
I could do this. The reason I haven't started already is that I'm concerned that it would interfere with my goal of writing 50 FI posts per month. I'd do this image upload project if it subtracted, say, 15 posts from my goal for the month.

Kate Sams

unread,
Jul 14, 2018, 10:15:09 AM7/14/18
to FI, FIGG
I think your choice on what to do depends on *your* values. What’s more valuable to you: the value you expect to get from writing an extra 15 posts this month or the value you expect to get from doing this project?

This might be off, but it somewhat comes off as though you view the 50 FI posts per month as a chore, and you want negotiate (with an authority) a cut back on your chores for the month.

Instead, think about clearly identifying *your* values at stake and then figuring out a solution that’s aligned with them.


Elliot Temple

unread,
Jul 14, 2018, 1:20:04 PM7/14/18
to fallibl...@googlegroups.com, FI
Are you asking *my* permission to change *your* goal about FI posting? It’s up to you.

Do you want to know what would help you more? You didn’t ask but I’ll answer anyway: 15 FI posts would help you more than coding one script *IF* you wanted to write them, enjoyed writing them, had topics you wanted to write about and/or get feedback about, etc. But don’t make yourself post, when you don’t want to – and certainly not to the exclusion of doing coding projects you’d actually like to do.

I’m guessing you would not have posted this if you wanted to write the 15 FI posts very much. If you were enthusiastic to write them, I doubt much would stop you.

If you find yourself not wanting to write FI posts, I suggest you try to pay attention to yourself: why don’t you want to? what do you want? what do you do? try to understand yourself more. gather information about yourself. do some tests too, like try writing one FI post and see how you feel or what happens (this is IF you’re able to want to begin the one post for test purposes). If you’re able to want to, write notes about yourself instead of just doing the introspection in your head. The notes could be major points so you don’t forget, or if you’re able to want to and know how, they could be more detailed and you could use freewriting as part of your thinking process.



FYI: 2 things about the script:

i wrote more info about it at:

http://curi.us/2041-discussion#c10126

and i think i know how puush works on mac. i believe you take a regular Mac screenshot (their software isn’t doing anything) and they just watch the desktop for new files that fit the naming convention of screenshots and then when they see one they upload it.

it would be possible for the script to work this way. could be good. but i’m guessing it’s significantly harder. having a run-once-on-command thing should be simpler/easier than an always running thing that has to register with the OS to get notifications for file system events or whatever. there’s more room for errors with a permanently running thing than a user-activated tool. and hitting one extra hotkey per screenshot sounds ok to me (and gives me the choice not to hit the hotkey if i actually just wanted to save a screenshot. with puush it has a disable option or you can quit it. also puush doesn’t do anything about screenshots you take to the clipboard which are what i use in IMs, so i don’t often want to take screenshots to a file that aren’t for puush.)

Elliot Temple
www.curi.us

Elliot Temple

unread,
Jul 14, 2018, 1:34:14 PM7/14/18
to FIGG, FI
I agree.

I had the same reaction. I thought of the main point of my reply first:

> Are you asking *my* permission to change *your* goal about FI posting? It’s up to you.

And then saw your post was independently making the same kinda point.

The overlap isn’t just with Kate’s first sentence (with the “*your*” in italics just like mine). The concept of negotiating with an authority is also the same. I didn’t use the word “authority” but asking *my* permission would be treating me as an authority in charge of this matter.

I also picked up on the treating-as-chore signals, which are a reason I made comments about posting only being valuable if one wants to (rather than doing it under some kinda pressure, like feeling one has to – which is how chores work).


Elliot Temple
www.fallibleideas.com

Josh Jordan

unread,
Jul 17, 2018, 11:20:19 PM7/17/18
to FIGG, FI
On Fri, Jul 13, 2018 at 9:52 PM, Elliot Temple <cu...@curi.us> wrote:

> Would someone create the following for me?
>
> Tool that uploads the image on the clipboard to an ftp site i configure (give it a random filename to avoid collisions), and then puts the link on my clipboard.

Here you go: https://github.com/jordancurve/ssup

Elliot Temple

unread,
Jul 18, 2018, 1:19:21 PM7/18/18
to FIGG, FI
Thank you. The script was really helpful as a starting point, especially using pngpaste. And I'm not very familiar with bash stuff so that was easier to modify than write.

First I added an extra line to convert the image to 50% size so they wouldn't be too big. It worked but it hurt the quality.

Then I tried uploading the full size image and 50% size image, with retina naming conventions, and using the srcset attribute for an html image tag. This didn't do what I wanted. It was displaying the retina version for me, and than blowing it up to double size anyway. It wasn't treating it like a high resolution version as I'd hoped.

So then I decided to detect the image dimensions, halve them, add them to the filename, and add height and width attributes to the image accordingly.

This was distorting some images because it'd force the height or width to a specific value, while hitting the max height or width would force the other dimension to a non-proportional value.

The max dimensions are in CSS:

max-width: 100%;
max-height: 500px;

I fixed by adding another line of CSS:

object-fit: scale-down;

I wonder what browsers don't support this. Google says Edge added support for object-fit in image tags 2 years ago. Should be OK then.

So here's my updated script which adds the dimensions to the filename:

It also sets files to readonly before uploading so scp can't overwrite, rather than checking for a duplicate with curl. (Saves a network request.) It also adds -n when echoing the url to the clipboard so a newline isn't stuck on the end.

https://pastebin.com/uCByLe8z

The script includes, in comments, a secondary ruby script for getting image dimensions using sips and then halving them and outputting in the format I want. Below that, commented out, is the version which uploaded 2 images, a retina and non-retina.


NEW CONVENTIONS FOR MY BLOG:

if you do a markdown image tag in comments

and the image name is:

myimage-WIDTHxHEIGHT.ext

where WIDTH and HEIGHT are numbers

then it will set the width and height in the image tag that's generated.

if you have retina images, set the width and height to HALF the actual dimensions to scale them down to 50% so they show up at the correct (regular) size. this corrects an issue where, normally, they get doubled.


For hotkeying the ssup (screenshot upload) script, I'm using this shell script in automator:

source ~/.bash_profile
~/c/bin/ssup


the source line loads my profile and gets paths set correctly. totally broken without that.

i have an automator workflow which just runs ssup so i can hotkey that, and a second one which runs ssup and then types ![]( pastes and types ) (like i was using with puush before). the downside of the more complete one is you need to wait for it to finish, not run it in the background. i think i'll use it anyway. i think it's pretty fast.

so the workflow is:

1) copy screenshot to clipboard (cmd-shift-ctrl-4)

2) go to blog comments, place cursor where i want an image, hit hotkey for combo automator, wait a few seconds

alternative to (2) is to use ssup only automator and then use my existing markdown format paster. you can find the existing markdown format paster applescript code at:

http://curi.us/2123-improvements-to-comments


Elliot Temple
www.elliottemple.com

Alisa Zinov'yevna Rosenbaum

unread,
Jul 19, 2018, 12:20:00 AM7/19/18
to fallibl...@googlegroups.com, FI
On Sat, Jul 14, 2018 at 8:20 PM, Elliot Temple <cu...@curi.us> wrote:

> On Jul 14, 2018, at 6:20 AM, Alisa Zinov'yevna Rosenbaum <petrogradp...@gmail.com> wrote:

>> On Fri, Jul 13, 2018 at 11:52:39AM -0700, Elliot Temple wrote:

>>> Would someone create the following for me?
>>>
>>> Tool that uploads the image on the clipboard to an ftp site i configure (give it a random filename to avoid collisions), and then puts the link on my clipboard.

>> I could do this. The reason I haven't started already is that I'm concerned that it would interfere with my goal of writing 50 FI posts per month. I'd do this image upload project if it subtracted, say, 15 posts from my goal for the month.

> Are you asking *my* permission to change *your* goal about FI posting? It’s up to you.

No.

> Do you want to know what would help you more? You didn’t ask but I’ll answer anyway: 15 FI posts would help you more than coding one script *IF* you wanted to write them, enjoyed writing them, had topics you wanted to write about and/or get feedback about, etc. But don’t make yourself post, when you don’t want to – and certainly not to the exclusion of doing coding projects you’d actually like to do.

Yes, that's what I wanted to know.

> I’m guessing you would not have posted this if you wanted to write the 15 FI posts very much. If you were enthusiastic to write them, I doubt much would stop you.

Yes.

> If you find yourself not wanting to write FI posts, I suggest you try to pay attention to yourself: why don’t you want to? what do you want? what do you do? try to understand yourself more. gather information about yourself. do some tests too, like try writing one FI post and see how you feel or what happens (this is IF you’re able to want to begin the one post for test purposes). If you’re able to want to, write notes about yourself instead of just doing the introspection in your head. The notes could be major points so you don’t forget, or if you’re able to want to and know how, they could be more detailed and you could use freewriting as part of your thinking process.

Those are good, concrete suggestions about how to think more carefully about the problem and how to get more information about what's actually going on. I think I've been thinking about the issue too vaguely to be effective.

Here are some more vague high-level thoughts:

- It's sometimes hard getting started writing a post. But once I start writing, it's easier to continue writing posts for a while.

- I like writing FI posts, to an extent. I don't always *thoroughly enjoy* it though. It's a bit of a struggle.

- Sometimes I find that my commitment to myself to write 50 posts per month hangs over me like a cloud when I am behind. I sometimes think it would be a relief to find other ways to discharge that commitment.

- It's not objectively hard to write 50 FI posts per month. Given my existing lifestyle, ideas, etc., it's not yet *easy* for me to hit that goal. I think it will become easier over time. When I first started, a goal of 50 posts per month would have seemed far out of reach. Now it seems do-able, but it's still a stretch.
Reply all
Reply to author
Forward
0 new messages