After way too long of sharing images from my iphone to my linux laptop with email, I finally hacked something together in shortcuts which can get a photo to my laptop much faster!
I made three versions, each one syncs different sizes
links: sync1024 sync512 sync256
Long story short the Shortcuts app on ios is totally borked, but we can do this:
- encode image as base64 string
- ssh into server
- echo string into file
- decode file as image
- pull file onto laptop with rsync alias
Unfortunately, this least complicated example is hindered by the fact that if we try and send a full image as base64 text, we get an error as a result of the text being way too long and the process fails. To get around this I initially just resized the image down to a width of 256. This works very well if you want a small image, and with an alias (
pic="rsync -vazh [email protected][$MX_IP]:/home/benh/pic.jpg ./ && feh ./pic.jpg") on the laptop end it's probably the fastest way to send an image using the shortcuts app. The 256 version of this shortcut is linked above, because neither of the other two come close to how fast this version is, and I still have a few usecases for it.
To solve the problem of syncing much larger images using this method, things get slightly more complicated.
For larger images the 1024 shortcut resizes the image to 1024 (this is sorta arbitrary) and iteratively crops the image in 10 pixel tall bars that span the width of the image. By moving these crops down the height of the image and sending each cropped image to the server separately, we can send all of the image data without exceding the character limit. Then we just tell the server to combine the images with an ImageMagick command, and we're done! It does take much longer than the 256 version because loops in the shortcuts app are crazy slow, but might be worth it if you need a larger image.
The third version, sync512, uses a combination of the two previous strategies. It's hardcoded to crop a 512-width image into 8 horizontal subsections, which means you don't get the (seemingly arbitrary?) slowdown of a loop. The smaller resolution is just a result of it being an absolute pain to write shortcuts, and 8 crops (each of which require 4 commands) was the limit I was willing to make.
If you actually end up using this - first of all, dear god why? - let me know! If you have problems, just send me a message and I'll be happy to help :>