Prep version 0

in technology

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:

  1. Makes a folder named m
  2. Copies all .jpg files into m
  3. Resizes all .jpg files in /m/ to be 540 px wide (to fit my blog theme)
  4. 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.
  5. 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.


POSTID=$(basename $(pwd)) 

mkdir -p $MED 

for file in $(find . -iname "*.jpg"); do 
    cp $file $MED 

mogrify -quality 90 -resize 540x+0+0 $MED*.jpg 

echo "\<a title=\"CHANGE ME\" href=\"http\:\/\/\/u\/$USERID\/content\/$POSTID\/1.jpg\"\>\<img src=\"http\:\/\/\/u\/$USERID\/content\/$POSTID\/m\/1.jpg\" alt=\"\" \/\>\<\/a\>" | xclip -sel clip 

mv $(pwd) $PUB 
exit 0

March 20

in me

Your email address will not be published. Required fields are marked *