Did you have the problem before that you wanted to load some file formats into your Flash site but loadMovie does not accept them? Something like PNGs, GIFs or progressive JPEGs? Do you want to load images or SWFs from a different domain but the security sandbox is in your way? For these purposes I have written swfImageProxy, a PHP script that automatically converts file formats that are usually indigestible for Flash into something that it can display. On top of that it acts a proxy and is able to download images from other domains.
Here is a simple Flash demo that allows you to enter the URL of an image and swfImageProxy will try to retrieve and convert it.
If you want to use the full functionality of the script your server will have to fulfill certain prerequisites:
- For basic functionality you will at least need PHP with GD support.
- If you want the conversion of progressive JPEGs to baseline optimized JPEGs to be lossless the script needs access to the jpegtran utility.
- If you want to be able to read GIFs the minimum required version of GD is 2.0.28 which currently happens to be the latest version
- If you want to preserve the transparency of PNGs and GIFs they have to be packaged as SWFs. For this purpose the png2swf utility from the excellent swftools package by Rainer Böhme and Matthias Kramm has to be installed
- To convert animated GIFs you need access to ImageMagick
You can download swfImageProxy here. Currently I have only tested this on Linux - if you are able to run this on Windows I'm happy to hear about it. I have tried to make this as secure as possible, but of course you use this on your own risk. It also looks like the png2swf tool does not fully support every format of PNGs yet.
Thanks to Jon Williams for the initial inspiration!
Update: I have just fixed a bug that killed the transparency with 24-bit PNGs
so the latest version is swfImageProxy v0.2
Update: fixed the quality=0 bug that occured when you used GD only for conversion.
The latest version is now swfImageProxy v0.3
Latest update: I integrated an option to use ImageMagick for the conversion of animated GIFs to SWFs. Though it does not yet give optimum results for every type of GIF. Latest version: swfImageProxy v0.4Posted at September 14, 2004 02:12 PM | Further reading