I’m not sure if I blogged about this before, but hey. Whatever. I use Dropbox and I post a lot of images here – and as a matter of fact almost every image comes served out of my Dropbox/Public/content folder. I use a tidy little script for this, that I call prep. It’s extensible and easily changed, but the gist of what is does is:
- Makes a folder named
- Copies all .jpg files into
- Resizes all .jpg files in /m/ to be 540 px wide (to fit my blog theme)
- The image in the main folder isn’t touched – I typically export images at 1500px on the long side so I don’t need to alter them again.
- This script then moves the folder to your Dropbox/Public/whatever folder and generates a URL based upon your Dropbox ID.
There are two external dependencies: xclip and mogrify. These are fairly ubiquitous in availability through your distribution’s package manager. I have found them both freely available under Gentoo, Arch, Fedora, SuSE and MetaDebian (Debian, Ubuntu, Mint, etc. etc.).
It’s a KISS script. However, I’m bored and will happily take suggestions to tweak or otherwise add to this.
#!/bin/sh PUB=/path/to/Dropbox/Public/folder MED=m/ USERID=1234567 POSTID=$(basename $(pwd)) mkdir -p $MED for file in $(find . -iname "*.jpg"); do cp $file $MED done mogrify -quality 90 -resize 540x+0+0 $MED*.jpg echo "\<a title=\"CHANGE ME\" href=\"http\:\/\/ix.bhalash.com\/u\/$USERID\/content\/$POSTID\/1.jpg\"\>\<img src=\"http\:\/\/ix.bhalash.com\/u\/$USERID\/content\/$POSTID\/m\/1.jpg\" alt=\"\" \/\>\<\/a\>" | xclip -sel clip mv $(pwd) $PUB exit 0