Quick Tip: Use AS3 to Grab Exif Data From a JPG Image

Exif, or Exchangeable image file format is a specification for image formats used by digital cameras and scanners. It's also used to store metadata such as camera model, type, author etc. Learn to display Exif metadata in your application by following this Quick Tip.


Step 1: Brief Overview

We'll use an excellent library to load and parse the Exif information of a JPG file; the data will be then displayed in a Dynamic TextField. You can download the library from the developer's site.


Step 2: Set Up Your Flash File

Launch Flash and create a new Flash Document, set the stage size to 320x480px and the frame rate to 24fps.


Step 3: Interface

This is the interface we'll be using; nothing fancy, just a TextField in Stage called infoTF. The image will be dynamically loaded using ActionScript.


Step 4: ActionScript

Create a new ActionScript Class (Cmd+N), save the file as Main.as and write the following lines. Please read the comments in the code to fully understand the class behavior.


Step 5: Document Class

Remember to add the class name to the Class field in the Publish section of the Properties panel.


Conclusion

Use this library to access the metadata in your jpg file. Remember that some image editors remove the data when compressing, in which case an error will be thrown by the player.

I hope you liked this Quick Tip, thank you for reading!

Tags:

Comments

Related Articles