Necuima Posted February 3, 2014 Share Posted February 3, 2014 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 More sharing options...
Larry Posted February 4, 2014 Share Posted February 4, 2014 Here's the code: https://dl.dropboxusercontent.com/u/23610669/native_process.zip Huge thanks for sharing!!! Link to comment Share on other sites More sharing options...
quinnh Posted April 15, 2014 Share Posted April 15, 2014 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 More sharing options...
Larry Posted April 16, 2014 Share Posted April 16, 2014 Sorry about that. Let me see what I can do... Link to comment Share on other sites More sharing options...
Necuima Posted April 20, 2014 Author Share Posted April 20, 2014 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 More sharing options...
kb731811 Posted July 24, 2014 Share Posted July 24, 2014 Did anyone ever post permanent links to this solution? Would love to look at an example of flexair and a native process. Thanks! Link to comment Share on other sites More sharing options...
Necuima Posted July 30, 2014 Author Share Posted July 30, 2014 Hi, If Larry can't fix the dropbox link, I will ask Larry to send you my email address, then you can email me and I will attach the code as files. Cheers from Oz. Link to comment Share on other sites More sharing options...
Larry Posted September 12, 2014 Share Posted September 12, 2014 So sorry for the delay! I was able to hunt this down (Necuima had previously sent it to me) and recreate a dropbox link for it: https://dl.dropboxusercontent.com/u/23610669/native_process.zip Huge thanks to Necuima for doing this and pursuing it. Link to comment Share on other sites More sharing options...
Recommended Posts