Patrick Shyu | for all the fans out there

Archive for September 2009

It’s not possible to execute external applications in Adobe AIR Actionscript 3 (part of the security sandbox). I figured this out while trying to run Imagemagick’s convert.exe command to resize images for the TinyUploads project. Although Actionscript 3 provides some ways for resizing images (BitmapData.draw with smoothing turned on), that simply cannot match the quality of the widely known Imagemagick tools.

Fortunately, you can use FluorineFX’s Aperture library to run external applications in Air. It’s free, best of all. There are also other programs like Shu, but that’s commercial. So, using FluorineFX, the command is simply:

// in your MXML file:  Instantiate aperture
<aperture:LocalObject id="m_fluorine" showBusyCursor="true" 
source="apsystem:26338E77-36A6-46FF-91CA-79E91079A81C" >
</aperture:LocalObject>	
 
// Elsewhere in the code... when you want to execute a shell command:
m_fluorine.Execute("open", "C:/Program Files/ImageMagick/convert.exe", 
"-geometry 300x300 source.jpg target.jpg");

Check out TinyUploads by the way if you’re looking for a great way to share photos. It’s pretty useful.

No tags