In the last few weeks, I have written:

This post I wind up this little technical series on image-handling and explain how I’ve now devised a way to tie the uploading of images into the publishing of a post.

With the latest workflow code, all one need do is put an image in the correct folder, reference it in your post and when you publish, the image will go with it. All whilst sticking to simple Markdown conventions and one additional rule.

Generalising the upload procedure

Last post, I talked about testing the uploading of images to Picasa using a specific file slug. That formed part of a script called test-post-photo.sh which took a file called mongolian-flower.jpg and uploaded, giving back its new location on Picasa.

I’ve now generalised this procedure which sits in a file called post-image.sh. One can call this from the command line with the name of an image as an argument. Assuming the image exists and is sitting in the right place under the images folder, the script will upload it to the relevant Picasa album. The address again is returned and used to update imagemap.csv so we have reference-to-address mapping.

The script will now also check imagemap.csv to see if the key already exists. If it does, the photo is not uploaded and duplication avoided. An -f flag can be used to override this check.

Automatically using the procedure

However, with some new modifications autoscrp.sh (the script I’ve created to post directly to Scriptogram), it’s possible that you’d never need to use post-image.sh.

The modifications mean that when an image reference is found, it’s checked against imagemap.csv. If the reference cannot be found there, the script has nothing to substitute the reference with, so it runs post-image.sh with the -f flag and the reference as an argument. Assuming no errors are encountered (some error-handling is in place), the image is sent to the album and the reference put directly into the post content as well as imagemap.csv.

This means there are just two steps to now including an image in your post:

  1. Put it in the right place.
  2. Reference it in your post.

Publishing will take care of the rest, at least as far as Scriptogram and Picasa are concerned.

This enables continuation of writing in a channel-neutral fashion with the scripts taking care of the specifics.

What next?

With the basics of image-handling handled, I can potentially move onto posts that require use of images!

I could do with reorganising the structure of the folders in my workflow to keep code, account data, and content separate from each other. Then I can start exploring making this work with other blogging and image-hosting services.