The Treachery of NSImages

Thanks to my recent bout of unemployment, I’ve finally been able to finish one of the projects I always said I’d do when I got free time. This one is to write a complete app for Mac OS X, from start to release.

The app is called Incisor, and it’s a lightweight image editor. I’m always finding pictures I want to use in blog posts on websites, or Flickr, or from my own iPhoto library. But getting them in a usable format means having to crop and resize them in Photoshop or iPhoto, both of which are overkill for doing something as simple as sizing an image.

It’s such a common task I’m surprised it isn’t being done already, but I haven’t found an app that works exactly like I want — in particular, being able to see a real-time preview of the edit, and being able to drag it directly into another program without saving it as an interim file. (Of course, now that I’ve put it on the internets, I’ll probably hear of a dozen programs that already do that. But what the hell; I wanted to learn how to write a Cocoa app anyway).

The thing about programming for Cocoa, at least from my limited experience, is that it’s crazy powerful, but it takes a lot of work to get your foot in the door. There are plenty of excellent tutorials out there, but they either start out too high for the beginner, assuming that you already know the basics; or they are so tailored to a specific task that you’re screwed if you try to do something different. I wrote the “Currency Converter” app about four times, each time ending up with a complete program but never understanding how all the pieces fit together.

I’ve read in more than one tutorial that the mantra of Cocoa programming is, “If it’s hard, you’re doing it the wrong way.” And it’s mostly true; the problem is finding out the right way to do it. Several times I would spend hours writing a bunch of functions to do something, only to have to delete it all once I discovered it was all covered automatically by one call to the system frameworks. For example, everything complicated about image manipulation is handled automatically by the Cocoa libraries — the effort in writing this app was half connecting the UI, and half digging through tutorials and documentation to find out what was covered and what I’d have to write myself.

And I’m just finding out now that at least half the UI code I’ve written could be scrapped if I’d used a different method. I guess I’ll know better next time.

I’m not sure if it’s just my experience, but developing something for OS X at the moment seems like a lot of super-powerful pieces without enough to tie them all together. It’s almost ludicrously easy to get a full-featured app out of the built-in frameworks and tools they give you for free; you can write a functioning web browser with just one line of code, for example.

Still, there’s not really anything guiding you through the process. For a while, after seeing how powerful InterfaceBuilder and Xcode are, and how deeply-integrated AppleScript is into everything, I was starting to think that development had gotten to the point where something like HyperCard wasn’t necessary anymore. But now, after finishing an app (albeit a very simple one) and looking back on where my time was spent, I’m convinced that the system really needs something that casual programmers and even non-programmers can use to get results not built into the stock iLife apps. Bring back HyperCard!

P.S. The app has some of the ugliest icons possible. If anyone wants to volunteer to make new ones, let me know.

Related

9 thoughts on “The Treachery of NSImages”

Heh, I wrote one about a year ago called Snaplux, but I’ve never released it. It pastes, crops, resizes, FTPs, and generates HTML (which it puts into the clipboard), so it’s ready to be pasted into a Blog. It even is similar in the way images are acquired; you can only paste into Snaplux, there’s no “open” option. I have to post screenshots, because Incisor looks eerily close to mine.

Note in the image below: the ghosting outside of the crop box, the style of the crop handles.

There are some differences. Snaplux’s resize option is in the Publish tab. This is because cropping is always done on the full size original image, with the resize happening at publish time. Also, I never got rotation, flipping, and cool things like Drop Shadow in, although at one point I had dreams. And there’s the whole file naming/code generation for the FTP publish and HTML generation.

Thanks for the screenshots, Hanford. (I edited your comment because WordPress doesn’t seem to like empty anchor tags). I can almost 100% guarantee that it was easier to write my app than yours, since Cocoa has so much fancy image-processing stuff built in, stuff I don’t remember being in Windows. But then, it’s been years since I’ve written a Windows app.

And sure enough, as soon as I put the app on one of those shareware announcement sites, I found three other Mac apps that do the same thing. So it’s not exactly an untapped market.

Still, you get to a point where it’s past functionality and is just about what “feels” right to you. And it’s kind of neat to have an app that does exactly what I need in exactly the way feels natural to me, because I could write it myself. It sounds like a corny Mac switch ad, but there’s really something to it: programming for Windows felt like a chore, but programming for OS X is somehow more satisfying, like I’m just modifying an app to work exactly the way I want it to.

Thanks for fixing my comments. I totally know the feeling you’re talking about — being able to solve a problem in the exact way you want to. I had specific requirements for how the cropping worked in my tool, and I also wanted to be able to set a final image size and then go back and play with the crop. The result was a program that does exactly what I want. And I bet you’re 100% right about Incisor being easier to write than Snaplux; I never released it because I never fixed the bugs because I just got tired of working on it. Oh well.

Still, you get to a point where it’s past functionality and is just about what “feels” right to you. And it’s kind of neat to have an app that does exactly what I need in exactly the way feels natural to me, because I could write it myself.

The power of custom software is not to be underestimated. I’ve always been a roll-your-own kind of girl, and now I’m just spoiled by it. With Snaplux, I’m doubly-spoiled, since when I want something a little different, I don’t have to tweak it myself, I just have to lean back in my chair and say “hey, hun? wouldn’t it be neat if Snaplux…”

I’ve been using Snaplux since Hanford first created it, and I sincerely can’t fathom how I managed to post images to my blog before I had it. It was a relative pain in the keister, that’s for sure. I’m surprised that there’s not a few more obvious solutions floating around out there.

Now, if Hanford takes up smoking and you take up tiki bar hopping, I’m going to be seriously freaked out.

I’m sure it’s me, but when I downloaded it, I couldn’t get it to work. It would look like it launched, but then nothing would happen. I’m ‘tarded when it comes to this kind of thing, though, so perhaps I am doing something wrong? Download, open, drag icon to my applications folder and launch, right?…

This is a nice program to have around. I used to use Goldberg for resizing (and it does other handy stuff), but one day it just stopped working, and I can’t get it back to working. (Maybe one of the OS X 10.4.x updates broke it; the author doesn’t respond to e-mail.) But mostly what I need for daily use is resizing and cropping, and Incisor is just great for those needs.

I’m glad to hear it’s useful! I’ll keep up with the updates as best I can, so check back at the software page occasionally. There are still a couple of annoying glitches with it. Two things I plan to add at some point: batch processing, and CoreImage effects (contrast, saturation, etc.)

And I’d never heard of Goldberg, so there’s yet another free app that does the same thing (and is better at being backwards-compatible). Apparently if you want to make it rain, you wash your car, and if you want to find a good OS X app, you write one that does something similar and put it up on the internets.