Flash "/>

Handling user upload of big images

28 January 2010 at 8:17 pm

Working a lot these days so few posts, but I made a class for a project that some may find handy. When you let users upload pictures using the Flash Player 10 local FileReference feature, you can get all kinds of image sizes (and content!). Most modern cameras have quite a few megapixels and Flash Player 10 can easily choke on large pictures.

FP10 has problems with images that have width or height larger than 8191 pixels. This is still much better than the 2880x2880 pixels we had to work with in FP9 so that alone is a great reason to insist on FP10 for this kind of applications. There is also another limitation mentioned in the official documentation that says “the total number of pixels cannot exceed 16,777,215 pixels”. I’ve found that this isn’t a problem for this implementation, so users can easily upload 8000x8000 pixel images without causing problems. The class will take the uploaded image and scale it to whatever max size you want. If the uploaded image is smaller than the max, it’ll leave the image unchanged.

Using the class is straightforward. Just make an instance and pass in what you want returned as the maximum width/height:

var bigImageHandler:BigImagehandler;<br /> bigImageHandler = new BigImagehandler( 1500 );<br />

and then add listeners to respond to what the user does:

bigImageHandler.addEventListener(Event.CANCEL, userFail);<br /> bigImageHandler.addEventListener(Event.COMPLETE, userSuccess);<br /> bigImageHandler.addEventListener(Event.CLOSE, userCancel);<br />

Click here for example (Source code)

The project I did this for is also quite cool and I’ll give a small presentation of it on the next FUGN meetup. It’s a small app that’ll allow you to make yourself old. Just upload an image (or use a WebCam), position facial features and you can turn on/off wrinkles, hair and more. Feel free to give it a spin! Click the image my old self to get started making your own. (Note: the app is in Norwegian, but I’m sure you’ll figure it out by just clicking around)

bligammel.jpg