Jump to content
Larry Ullman's Book Forums

Example Of A Flex/air Native Process


Necuima
 Share

Recommended Posts

Hi,

 

After a bit of sweat and tears, I finally managed to get a FLEX/AIR native process to work and Larry encouraged me to post it in case it is of interest.

 

A bit of background:  Since the publication of Larry's book, Adobe released version 4.6 of FlashBuilder as well as the 4.6 SDK. This and subsequent versions support a capability called 'native process' which enables a FLEX/AIR application to call another application which would normally run in a DOS box (Windows) or the equivalent in a Mac.

 

This capability enables you to put a user-friendly front end (UI) onto an application that would normally run in a DOS box.

 

Larry will shortly post my code which is an example of using native process to invoke ImageMagick to resize jpg image files - one by one.  ImageMagick is available free to download from the 'Net and is a very powerful image processor - it can resize images as well as do heaps of other neat things with image files.  So in a sense my example only scratches the surface of ImageMagick's capabilities, nevertheless I have found image resizing useful.

Anyone trying this will have to edit one line in the mxml code and that is the exact location of the ImageMagick convert.exe file in their environment.

 

I have left quite a few comments in the code which I hope will be of value.

 

I found a couple of traps along my native process learning journey - firstly the xml file has to have the extended profile added to it - see the bottom of the xml file.  Secondly, if you are using FlashBuilder to create the file which will subsequently be transformed by AIR into an executable, you need to export release build it as a 'signed native installer' otherwise you will get errors if you try to export release build it as a 'signed AIR package' (it took me ages to get that bit right!).

 

Re the resizing functionality: the user first selects a jpg image file to be resized from the user's desktop or PC.  Then it needs the new size parameter to be filled in (in pixels).  The value will be the new image width for a landscape image or the new image height for a portrait image - in either case the image aspect ratios are preserved.  Then the UI asks you for the image quality value to use for the processed image - the higher the quality parameter the larger the resultant image file will be. I have found that a quality parameter value of about 75 to 80 still yields good image quality with smaller file sizes. Once the processing is complete, the new image file is written out to the user's desktop/PC with a 'resized' file name suffix (in the same directory as the input image).

 

Note that the usual pixilation problems will appear if you try to increase the size of the image, as the program is written to only enable the selection of a jpg file.  Though this could be changed to select a lossless image file format but you'd need to change the file selection filter.

 

Note: this application runs on the desktop (so that it can access the file system) thus is not a browser-Flash application.

 

As mentioned above, Larry will post the code in case anyone wants to try this.

 

Cheers from Oz!

Link to comment
Share on other sites

  • 2 months later...

Is there any way to put up a permanent link to those files? I'm in the exact same scenario of trying to use ImageMagick in an Adobe AIR project, would love to see some examples to help trouble shoot any problems. 

 

Thanks,

Quinn

Link to comment
Share on other sites

Hi Quinn,

 

If Larry hasn't been able to fix the access to the code, maybe I can help.

I could maybe email it to you but then I'd need your email address.

The best way is probably via a dropbox.

 

Let me know if I can help.

 

Cheers from Oz, Necuima.

Link to comment
Share on other sites

  • 3 months later...
  • 1 month later...
 Share

×
×
  • Create New...