Field of Science

Free ImageJ Macro -- for citing images

(of course all IJ macros and IJ itself are free...)

So I got sick of constantly clicking away just to resize an image and add some citation text to the bottom and then name the file that exact thing; in fact, it was a deterrent to blogging -- yes, I am *that* lazy, apparently. At 4 in the morning today, my latent inner yet-unexplored codemonkey decided it needed an ImageJ macro for doing that, and it needed it then, at 4 in the morning, the day before I fly for holidays, and therefore a very busy day. After a couple hours of failed negotiation attempts between brick walls and my head (and much profanity), I finally produced a piece of code that not only does something, but does what I want it to! Being an utter failure at anything technical (engineering aptitude turns out to not be particularly heritable, as my parents' experiment demonstrates), I get soooo excited when something I slap together out of copy+paste and single-finger typing on the keyboard actually works, that I absolutely have to share it with the world. Even if it's pathetically minor and useless. Shhh.

World, behold -- an ImageJ macro for adding citations to images!
// This macro creates citation (or other input) text by adding a 20p strip to the bottom of the image, aligned right
// Image is saved in Documents as the ref input text
// WARNING: saving several images with same citation input WILL result in overwrite!

ref=getString("Reference", "ref");
var width = getWidth();
var height = getHeight();
run("Canvas Size...","width=&width height=&height position=Top-Center");

var textwidth=getStringWidth(ref);
var textmargin=width-(textwidth+5);
drawString(ref,textmargin, height-5);
var path="C:\\";
var name=path+" "+ref;
Hopefully this means I'll get back to regular blogging soon, as one more Gate of Laziness has been removed from the path. Now if only IJ could also upload and link those images...

1 comment:

Markup Key:
- <b>bold</b> = bold
- <i>italic</i> = italic
- <a href="">FoS</a> = FoS