Photo Corners headlinesarchivemikepasini.com


A   S C R A P B O O K   O F   S O L U T I O N S   F O R   T H E   P H O T O G R A P H E R

Enhancing the enjoyment of taking pictures with news that matters, features that entertain and images that delight. Published frequently.

Solving Two Software Problems Share This on LinkedIn   Share This on Google   Tweet This   Forward This

21 August 2015

When we have a problem around here, we just switch hats. We have a fading WordPerfect cap for editorial duty, a straw hat for phone interviews, a fedora for doing reviews, a Ferrari ball cap for coffee breaks and a wig for programming.

Our Hats. Problem solvers.

Yes, a wig.

There's no task around here that requires as much sleight of hand as writing software. You almost have to transform yourself into something else to get the job done. Hence the wig.

A SIMPLE EXAMPLE

Take, for example, the other day when we decided we wanted to use an animated GIF in a story we were writing. Animated GIFs are making a comeback, not just as clever repartee but as efficient software support video.

Our usual method for making an animated GIF is to use Photoshop. And we're not alone. But we make animated GIFs so infrequently that we never make one twice in the same version of Photoshop. And the method seems to change in every version, so we always have to look it up.

But this time it was ridiculous. The trick was to recognize an obscure label as a button to click to see the options you need. Almost nobody sees the label as a button because it isn't drawn like any other button. It took a long time to figure that out.

The Wig. Sometimes....

So we put on our wig.

And we started making animated GIFs with a one-liner we found on the Web. In Terminal (with ImageMagick installed), we just typed: convert -delay 120 -loop 0 *.png animated.gif.

We turned that into an AppleScript with a duration (-delay) we liked and looping forever (that zero) onto which we would drag the set of images (*.png) we wanted to process into the animated GIF (animated.gif).

But that's a lot of variables. And variables are things we might want to change from one GIF to the next. So we thought we'd like to fancy up the interface to include not just the files, but the duration and whether or not to loop (which were fixed in the AppleScript) and what the filename should be.

We got that cooking in Xcode but, like everything in Xcode, it wasn't easy.

Then we thought we really ought to be able to vary the duration of each image just as you can in Photoshop or we'd end up back in Photoshop trying to figure out how to make an animated GIF again.

So we did that.

Gifone. Our animated GIF solution.

And we would have given this away to our subscribers as a benefit except that convert by itself is useless so embedding it into the Xcode project didn't fly. It requires a library and to get it to work with the library you have to recompile it. And life is short when you have a lot of hats to wear.

So we just pointed our Xcode project to the installed convert. You'd have to install ImageMagick (another monumental task) to use our GIF creation software.

But notice: we ended up with what we needed. We'll never have to figure out the Photoshop interface for animated GIFs again.

A COMPLEX EXAMPLE

We write Photo Corners using a simple text editor. And it's free. The one we've used for years and years is TextWrangler from Bare Bones Software. It does everything we need and has some built-in efficiencies that are just to die for.

But every now and then something breaks. We had trouble with dialog boxes to open a file in one version. And Spell Catcher's auto correct was broken in another (and never fixed, not that there was anything Bare Bones could do about it).

That stuff happens. You adapt and move on.

But that dependancy caused us to become intrigued by Atom, the hackable text editor. Imagine being able to fix things yourself.

It's still early in the game (just version 1.0) but there's a lot to like about Atom. So we've been experimenting with it.

One thing we immediately missed, though, was TextWrangler's Text Filters. We have a nice long Perl script that performs several hundred text substitutions to standardize wild and wooly text to our publication style. We just pull down the Text>Apply Text Filter menu and select it to run on a whole story or a selection.

We spent some time trying to find out how to do that in Atom. It's extensible by writing a package in CoffeeScript, a JavaScript dialect. But we didn't want to convert our Perl substitutions (something Perl is rightly prized for) into JavaScript. Because, you know, we are constantly adding to the collection and didn't want to support two versions in different languages.

And while there are packages to execute whatever's in the text buffer (assuming it's code of some sort), there are none to execute a Perl script on the text buffer.

So we put on our wig again.

We'd been using Keyboard Maestro text macros to do things like change case, hyphenate words, swap characters, add HTML tags and more. They worked fine in Atom.

Keyboard Maestro Macro. Not a workaround but an improvement.

And sure enough Keyboard Maestro can run a shell script (or an AppleScript or JavaScript).

So we set up a key chord to copy the text buffer to a private clipboard, check that clipboard to see if it's empty and, if it is, select all of the text buffer and copy that to the private clipboard. So the macro has either a selection of the text buffer or the whole thing to work on.

Then we store what's in the private clipboard to a variable that our Perl script reads and performs its magic on before replacing the selection in our document with the result.

We ran some tests and the Keyboard Maestro version produced identical results the TextWrangler text filter. Moreover, the Keyboard Maestro version can be run in any application, even in TextWrangler (where it was suspiciously faster than the text filter).

CONCLUSION

Software development has become infested with buzzwords and half-baked technologies but it remains about solving real-world problems.

Photoshop's code base is getting overhauled (again) and there are some rough spots. GIF animation, though, suffers from an impossible user interface. But with some free tools, you can build your own. Our hats GIF above was built by our GIF animation tool Gifone.

Atom is built on the latest and greatest frameworks but it didn't do something essential that the older TextWrangler did. And coming to the rescue? A keyboard macro utility that goes beyond the call of duty. This story was copy edited with that new macro.

Knowledge is something you have to continually acquire. There's some great stuff out there, which makes that task fun. Intelligence is something else. You want a software developer who exhibits intelligence. You can tell just by looking. They wear a wig.

Because, let's face it, often it just isn't enough to wear a different hat.


BackBack to Photo Corners