[go: up one dir, main page]

Showing posts with label APIs. Show all posts
Showing posts with label APIs. Show all posts

Tuesday, May 20, 2014

OS X SIPS Command

It's better to pass command line args as an array than a string.
If you've ever needed to rotate, resize, or convert an image, programmatically, then take a look at the OS X SIPS command. SIPS is a highly optimized part of Core Graphics (Quartz) designed for the Automator app. It's been around for nearly a decade (Tiger 10.4). I first heard about it when chatting with another Apple engineer who was developing it in Cupertino.

Since Java's early days I have been manipulating images inside of web apps. In the 1990s, Java image manipulation was very crude and slow. If I recall correctly, it could not be done, easily, on a headless server. I believe it required instantiating a Java applet (canvas) to do the manipulation, hence the need for a windowing system.

I've tried other Java image APIs including ImageMagick, but none could hold a candle to OS X's SIPS when it came to speed. The first time I tried SIPS, in 2005, I resized a 24 megapixel image into a thumbnail. When I hit enter the command prompt immediately returned so I thought it failed. It turns out it worked, flawlessly. A quick call to the command line is an elegant and simple way to implement SIPS in Java, or any other language. If you want to get fancy, you can spin it off in it's own thread so it doesn't block. As always, be careful to avoid any race conditions. (Now that I think about it, it's probably a better idea not to spin it off in it's own thread until you need to scale your code.)

I used SIPS exclusively with my photo sharing website (Epics3) that let users upload photos for storage in their own S3 bucket as a static web page. Although the Epics3 (and Adjix) servers are now defunct, along with Posterous, my images live on in AWS S3:
http://pics.joemoreno.com/2gi3

The downside of SIPS is it hasn't been continuously developed. Some of the things it can't do is overlay text or read GPS EXIF metadata.

But, after reading Dave Winer's request for a text image overlaying API, it got me thinking again. Especially when I proposed this idea for Twitter 519 days ago. I'm surprised there isn't already a popular text image overlaying REST API. Perhaps soon, very soon, there will be the API we seek.

Saturday, January 25, 2014

APIs for Government Services

I recently befriended a guy who used to work in the mayor's office. During his tenure he oversaw several key transportation initiatives related to making the city more green and efficient. After speaking with him an idea came to mind regarding the importance of opening up government data to third parties via APIs. This is, by no means, a new idea, but it became obvious to me what can be gained once that happens.

Currently, if I want to access my DMV information, I have to visit a website developed by the government. Government websites are notorious for their poor design. Yesterday, I visited an FAA website to make an affirmation and this is what I saw...

Click to enlarge

I spent a couple minutes looking up and down the webpage wondering where to click to register my affirmation. I finally discovered that the entire green shaded area was a "button" to click on for affirmation. Although spelling out "click here" is usually a poor design choice, this is clearly a case where that would have been helpful. Even better would have been a simple button reading "I Affirm." If you look closer at the screen shot, you'll see there's actually a second button (the mauve shaded area) below the green one.

Data Wants to be Free

The reason I harp on poorly designed government websites is it would be simpler for governments to mind the data and let third parties design the websites and apps to disseminate it. Much of this data should be in the public domain, such as where a bus, train, or letter carrier is at any given time. Private government data, like my DMV information, can just as easily be accessed without compromise in much the same way that third parties access your Facebook or Twitter account.

The private company, Car2Go, does a great job at sharing data. Car2Go has their own free app and they publish their car data APIs for third parties to access and develop against. Car2Go doesn't make any more or less money if a customer uses their app or a third party app. Third parties are incentivized since they can sell their apps. Car2Go makes their money on the car rentals while third parties make their money selling their own apps.

The next time you find yourself on a marginal government website think about how great it would be if a professional web design firm got a hold of it.