Ming - a SWF output library and PHP module


Spent a few hours working with the Ming Reference documentation, generally cleaning bits of it up, making some of it easier to read, and so on.

Theres a lot more than needs to be done, however a fair number of people are joining in with a few moments here and there, each making a little bit of improvement.  It's definitely helping.  :)


SourceForge, where our development source code is hosted, are having problems and their status page says developer CVS will be offline for some portion of this weekend.  We can't update any code nor release the next version until it's back online.  :(

Hopefully it'll start working again soon.  :)


Looks like 0.3 alpha2 was broken when used with PHP. We're working on releasing alpha 3 (or beta1) in the next few days... with working PHP support. :)


Next alpha release is out.  ming-0.3alpha2.  Lots of updates by Mohammad Haque and Klaus Rechert, adding Video Streaming and support for Mac OS X.  Thanks guys!  :)


Just applied the patches by goto <harpy AT lily.freemail.ne.jp> to CVS, so things compile properly again, and added his release of the ttf2fft program to our Files list.

Lots of new documentation is being added by Community Members into the Ming User Editable Docs (Wiki) which will make things much nicer for people!


Moved the existing Ming Tutorial to the User Docs (wiki) section, so everyone can add pages to it, update it as they desire (click the Edit link at the bottom), and keep it growing in general. :)

Just noticed that someone in Japan has begun adding documentation for the UTF-8 versions of Ming functions.  Excellent contribution! :)


Not a bad day at all.  Figured out how to get Solaris to compile Ming 0.3a, and Sander Vesik (of Sun and the OpenOffice.org project) pointed us towards the first of the fonts we can legally distribute.


Well, it's the second day in of my volunteering to put tarballs online and update the website.

So, on that note there are new links to Flash Font files online (FDB format) as helpfully pointed out by a Community Member, and also links to gazb's excellent examples of Ming source code for people to learn with.  Very much recommended.


First Alpha version of Ming 0.3 released!


Perl Graphics Programming from O'Reilly has a chapter on using Ming with Perl!

11.20.02 - Ming lives!

Thanks to all of you who pledged your undying support for Ming. Wolfgang Hamann has agreed to take over the development side of the project, which means I can leave Ming in very capable hands. At last, I'm free!

If you're interested in contributing code to Ming, please join the developer mailing list and alert the residents to your intentions. If you have a question about or problem with Ming, do send a message to the fine and friendly people on the ming-fun mailing list.

9.18.02 - want to run Ming?

If you're new to Ming, you've probably noticed that nothing much has happened in the last year or so- and if you've been around a while, you know I haven't spent much time on the mailing list except for the occasional flurry of activity. Getting a job killed all my productive time and getting a GameCube killed my weekends (but in a good way..), so I should just admit that I won't be able to work on Ming in any significant way and stop feeling guilty about it.

There's lots of stuff in the CVS that still needs to make it out to a public release, and probably plenty of bugs to hunt down. (I've noticed lots of segfaults in my web server logs, for one..)

So who wants to take Ming over?

8.11.02 - support for wide fonts in CVS

Ming finally supports 16-bit character fonts. Code in the sourceforge CVS. Example here. Bugs likely. Official release RSN.

6.8.02 - Ming home moved to sourceforge

I've finally decided to take advantage of the free web hosting at SourceForge for the Ming home page. It looks like everything works, but if you find any broken links, please let me know. Now I can move opaque.net into the office, ditch my DSL line (love my cable), and finally free myself from the tyrannical grasp of Qwest! Woohoo!

5.30.02 - a Ming tutorial

..by Navneet Behal, demonstrating using Ming to wrap images into SWF files on the server:


5.25.02 - opaque.net upgraded to PHP 4.2.1

..and it looks like everything's working. The 4.2.1 source at php.net now has the latest ming wrapper code, which means it'll work just fine with Ming 0.2a. My eternal gratitude to whoever slogged through my code to make this work.

4.15.02 - a wiki for Ming!

I'm embarassed to say I've had this together for a couple of months but never posted it, thinking I'd soon have the time to flesh it out more. I've finally realized that won't happen, so here it is.

What's a wiki? It's a collaborative document system that lets users add information.. Like a message board, only much cooler. This should make it much easier for you to find answers to your questions and get up-to-date information on Ming, since the wiki can be updated much easier than these web pages.

Feel free to add new pages to the wiki- but do try to make it marginally useful to others, won't you?

1.28.02 - no news

..is good news, right?

I'm working on fixing Ming's PHP-4.1 code, and making Ming work on OS X. But it's not free time I'm swamped with..

9.06.01 - stuff

Two things:

First, Jerry Jasuta, Wolfgang Hamann and the inimitable Martin Fasani have put together some Ming tutorials for your edification: http://www.neuralust.com/~mingdocs/.

Second, the user-friendly Apache installer http://www.apachetoolbox.com/ now includes Ming 0.2a!

8.17.01 - Ming 0.2a

Here it is, and only a month or two late. I've finally fixed the mp3 streaming, Flash 5 actions work (many thanks to Wolfgang Hamann who found a bevy of compiler bugs and added some useful features), plus Soheil Seyfaie has created a Perl wrapper! Here's the compiled PHP extension for Linux/x86:

php_ming.so for PHP 4.0.6
php_ming.so for PHP 4.0.7-dev (CVS)
If you're building from source, you'll notice that the php_ext/ dir has two versions of ming.c, one for 4.0.6 and one for 4.0.7- just copy whichever you need to ming.c before building. If you're trying to build ming into an older version of PHP, good luck- you're on your own.

Documentation is forthcoming, as always.


Here's a chronicle of one man's adventures in installing Ming on Debian.


I'll be in NYC for the next week, so if you email me don't expect an answer for a while. (If you expected an answer at all..) In the mean time, here's some random cool stuff- first, an SVG to SWF translator. I'm really amazed how well it works.. Also, an XML to SWF thingy. Haven't played with it myself, but it looks cool.


There's an article about Ming at ONLamp.com, some kind of O'Reilly gig. I, uh, haven't actually read it yet, but it looks like.. an article about Ming. Remember not to click on the evil DoubleClick ads.

And, yes, Ming 0.2 should be coming out in the next few days..


This is old news, but I've been slow: Armel Grignon has built a search tool for the ming-fun mailing list.


Here's a sneak preview of a new Ming feature, Flash 5 actions. That's right- we did it first, but now we're catching up again. I'll put the code into CVS as soon as SourceForge wakes up. Official release as soon as I get some idea how many people will hate me for dropping support for Flash 4 action code.

Even more exciting, Jonathan Shore has written a Java wrapper for Ming, bringing the number of Mingified languages up to.. I don't know, a lot. That code's in CVS too, which again means it's out of reach until SF brings CVS back online. Until then, suffer.


Flash sound guru Martin Fasani is hosting a ming forum. And other fun stuff, too.

And Armel Grignon has created a very cool text effect webtool with Ming.

4.13.01 - Ming 0.1.1

Wacky New Data Handling

In the PHP wrapper, the SWFBitmap constructor and SWFMovie->streamMP3 functions now take filehandle or big-wad-o-data arguments. That means you can pass in an fopen'ed url, a blob from your database, or whatever- but not the filename!

$s->setRightFill(new SWFBitmap("foo.jpg"))

$s->setRightFill(new SWFBitmap(fopen("foo.jpg", "r")))

Yeah, I said I wouldn't be so casual about changing the api after 0.1.0.. But I say a lot of crazy things, don't I?

Under the hood, this is done with the new SWFInput object, which attempts to abstract data sources like buffers and file pointers. You probably don't need to know that, but if you go digging through the source and see that, that's what it is.

Handy Bitmap Shortcut

Now if you add an SWFBitmap to an SWFMovie, Ming wraps it into the properly-sized SWFShape for you.

Better Error Handling

Ming now has settable error handlers so we can propagate errors up into the wrapper code- no more embarassing and unsightly core dumps.

Updated c++ Header

Finally. Sorry about the delay. Also, it's called mingpp.h now and gets installed in your include dir alongside the ming.h header. Now that's convenience.

3.18.01 - Ming 0.1.0

This one fixes that annoying scaling problem- y'know, where ming movies loaded into flash movies at 1/20th the size. Fixed. All of the scalar data pass through scaling wrappers now. You have control over the scale, though, so to make all your old code work just do


for the "classic" scale. (Just so you know, the default scale is 20.) If you have no idea what I'm talking about, good. The interface is the same, except now you can use floats for scalars.

mp3 compatibility is improved, too, I hope. Lots of other small bugs were fixed as well but I forgot to write them down.

Also, ming-winutils.zip is some of the ming util progs for windows/dos: listswf, listfdb, makefdb, and png2dbl are here. I can't seem to get libungif installed in my cross-compiling environment, so gif2dbl and gif2mask aren't in there. So sorry.

And, here's the Ming docs in htmlhelp (.chm) format. Many thanks to Korakot Chaovavanich for putting this together.

Finally, php users should note that php 4.0.5dev (php4 in cvs) requires Ming 0.1.0.

2.13.01 - Ming CVS Access

The guys over at sourceforge have anonymous CVS working, so now you can impress your friends with the latest cutting-edge source code. Well, actually, it's not really moving much at all, but if you spot a bug and I fix it I'll post the patch into CVS long before posting a new release.

cvs -d:pserver:anonymous@cvs.ming.sourceforge.net:/cvsroot/ming login
(just hit return when it asks for a password)

cvs -z8 -d:pserver:anonymous@cvs.ming.sourceforge.net:/cvsroot/ming co ming

If you want write access to the ming CVS tree, email me with your sourceforge username. No telling when you'll actually be able to access it, though..

And hey, speaking of bugs- why not try the sourceforge bug tracking system for reporting bugs instead of emailing me? That way I won't just let it get lost in my inbox and never get around to it..

2.05.01 - Hallelujah!

I don't have to worry about figuring out how to build RPMs of ming anymore because Troels Arvin has done it for me:

http://rpms.arvin.dk/ming/ has the ming library itself, and here's the i586 and i686 versions of the php module. 1.25.01 - 0.0.9c

This version adds the drawCubic function for drawing cubic bezier curves, and a number of assorted bug fixes. And probably plenty more bugs.

$s->drawCurve(bx, by, cx, cy, dx, dy);
$s->drawCubic(bx, by, cx, cy, dx, dy);
both do the same thing: draw a cubic bezier from the current pen position, using the three given points as control points. To control how "tight" the approximation is, use the
function. This gives the amount of error in approximation that each subdivision of the curve needs in order to stop recursing. The default is 20000- if your curves are too sloppy, lower the number.

(Oh, and the approximation code is a little buggy, but it seems to work properly in all practical cases.)

Note that this version installs as a shared library- you should no longer have to tell php where it lives, but you'll have to do "make install" after you build the ming library. And "make static" does the traditional libming.a build.

Ooh, and here's a fun new example. Don't forget to roll your mouse over it!

1.21.01 - d'oh!-

I forgot to point out the ming python pyd for windows python users. "Mad props" (as the kids say these days) to Itamar Shtull-Trauring for this one..

1.17.01 - About that PHP API version problem-

Try this build of the php_ming.so: php4_0_3-ming_so.tgz if you were getting complaints from php about the API versions needing to match.

1.4.01 - 0.0.9b: more bugs fixed

Namely: instances don't pop back to (0,0) when you rotate or skew them, removing display items doesn't cause trouble in the python module, and.. some other stuff I can't remember. Oh, I finally ported all of the examples to plain c code. That was a real treat, believe me.

So grab it, try it out, let me know if it causes you any existential malaise.

1.3.01 - Documentation updated

No promises that it's all correct, but it's at least somewhat current now. Plus, it now includes the Python, C++, and C functions.

Here's the goods.

12.15.00 - 0.0.9: all you're getting from me for xmas

I was aiming for 0.1.0 this time but there's a fair bit of new code in here, most of it written at four in the morning, so I'm not willing to put the "stable" mark on ming quite yet. What's new:

c++ wrapper: actually just a huge header file which cleverly replaces the c structs with objects and provides the functions as object methods.

Optimized outputBlock generation: that's the thing that makes animation work. Ming used to put stuff in there it didn't need to. And even the wrong stuff in some circumstances. Now it doesn't. I hope.

Improved fill and line handling in shapes: used to be you'd have to declare all of your fills and linestyles before you started drawing. Not any more.

swftophp utility updated: now actually works! It doesn't do quite everything I want it to, but at least it's usable.

another fill shortcut: with php you can just do

now instead of
If this seems like a useful thing, I'll try and emulate it in the Python and c++ wrappers.

Here's the source package. Requires: PHP 4.0.2 or higher for PHP, Python 1.5.2 or higher for Python, and I have no idea for Ruby.

Also, here's a tutorial I've started. If you have suggestions for topics/improvements/whatnot (other than "stop being such a smartass") please do share.

11.20.00 - spank me

If you're having trouble with the Python wrapper code, here's replacements for ming-0.0.4/ming.i and ming-0.0.4/py_ext/ming.py that actually work. Those packaged with 0.0.4 don't feel like displaying text at all. Which is bad.

11.19.00 - 0.0.4: one step closer..

I accidentally fixed the memory leaks. I ran into an annoying freed memory read problem, so I loaded ming/php into purify, probably the most useful program ever written, to figure out what was going on. And then I just decided to fix all the leaks, too. So Ming is now a lot safer to use in a production environment. So I'll try and be better about leaving backwards compatibility in the script-level apis now.

Another swell thing that's happened recently is Steve Spicklemire has wedged Ming into Zope in a module called Zwiff. In a possibly misguided attempt to help the Zopesters out there, I fixed the ming.py interface to match the PHP api, so the PHP documentation should be valid and useful now. And, again, I tried to leave the old classes and functions working, but I might have missed something. If your old code doesn't work, let me know and I'll see what I can do.

Oh, and all of the PHP examples are available for Python now, check the "examples" directory.


..is today's new function. It draws a glyph outline into an SWFShape. This lets you do fun things like change the linestyle and fill properties, which you can't do with SWFText objects. Here's a PHP example.

10.24.00 - 0.0.3a: a new hope

I finally added a bunch of small things that I'd been putting off: gradients, color transforms, access to fill transforms, and probably a few other things I forget right now. One consequence of this is that a few functions have changed, so most existing code will need to be tweaked to work with this rev of ming. (Which is why this is new html here, I had to clean a lot of the example code..) Here's a summary:

  • SWFShape::setBitmapFill, SWFShape::setSolidFill replaced with SWFShape::setFill
    Okay, before I go any further- I'm talking in terms of the php interface here. Since it's mostly just a shallow wrapper for the c library, you should be able to figure out what these changes mean in terms of the underlying code (And good news there, too- the c header files are a lot cleaner now..) or another language wrapper if you're already familiar with it.

    So now there are separate SWFBitmap and SWFGradient objects; you just pass these to setFill and it figures out how it needs to deal with it.

  • SWFShape::setFillStyle0 and SWFShape::setFillStyle1 replaced with SWFShape::setLeftFill and SWFShape::setRightFill, respectively
    This should make it easier to figure out which one to use- setLeftFill means you're changing the fill that's on the left of the lines you're drawing in the shape- that is, it's on the interior if you're drawing the shape outline in a counter-clockwise fashion.

    The only problem is, this seems to be opposite for morphs. When I've set the fill in the way described above in SWFMorphs, it crashes the player. If your movie crashes, try swapping setRightFill for setLeftFill and vice versa..

  • SWFShape::addLineStyle and SWFShape::setLineStyle replaced with SWFShape::setLine
    Instead of making you keep track of line styles, this new function checks the shape's line style table for the style you request and only creates a new style if necessary.
    Now, a quick blurb about new features:

  • Color transforms
    These allow you to tweak the color of drawable objects. You can set a color to be added to the object, and a scaling factor for each of the rgb[a] components of the object.

    <small rant>Unfortunately, it doesn't let you define a matrix by which to multiply the color vector. That would totally rock, you could do hue shifting and grayscaling and other weird stuff.. But here you can only give another vector that gets dotted with the object color.</small rant>

  • Gradients
    About damn time! In striped and donut varieties. Or "linear" and "radial" if you wanna be all techy.
  • Transformable Fills
    This means you can set the center, scaling, rotation and skew for gradient and bitmap fills. This is a good thing, long overdue.


    Added rudimentary support for PNG bitmaps. Fixes by Tim Goetze add proper kerning table lookups and much less segfaulting to text operations.

    See the examples for usage, etc. Download here.

    Windows users! Achtung!

    Highly suggested you truck on over to www.php4win.de for all your binary needs. Reportedly has a dll build of ming that works on php-4.0.2 and 4.0.3-dev. Many thanks to those bold enough to deal with my mucky code.

    9/15/00 1.30am

    Was leaking a filehandle in the action compiler. Fixed now.

    0.0.2d - alpha masks for jpeg bitmaps

    Check the examples. Download source or .so module.

    in case you hadn't guessed..

    I've been busy.

    But the great thing about free software is that other people do stuff and you can take credit for it. Take Christian Becker, for example- he goes through all the trouble of building a dll version of php/ming, sends it to me, and now I get to put it here and let it make me look good. Doesn't seem fair..

    So anyway, here's the skinny: just take it, put it in your php extension directory (or just \windows\system) and add "extension=php_ming.dll" to your php.ini file. Or force-load it in your scripts with dl('php_ming.dll').

    Two notes: this .dll only works with php-4.0.1pl2 (and maybe previous versions, but not 4.0.2), and font loading doesn't seem to work.

    Also, in a vain and selfish attempt to steal some of Christian's glory, I've made a php_ming.so library so the unix people who install binaries instead of building from source can use ming as well. Same installation as above, more or less, though I build this one on 4.0.2, so older versions might not work. To find your php extension directory, run php-config --extension-dir.

    new release 0.0.2c
    Many fixes (and probably lots of breaks, too) to the compiler, an swf->php utility added. It's not perfect, but it might help you see how php/ming works, 'specially the action script stuff.

    download 0.0.2c

    Uh, just figured out why I wasn't getting any more subscriptions to the announce & user lists. Here's the linkage again:

    ming-announce - announcements only, average one message a week.

    ming-fun - fun with Ming! Tell us what you're doing with Ming! Ask questions about Ming! TALK ABOUT MING, damnit! average zero messages a week.

    Together, at last- Ming and Python!

    Okay, I'll admit it, I know absolutely nothing about python. But that won't stop me from heaping enormous praise upon these fine folks who made a set of python wrappers for ming:


    Anything that makes these infernal micro-computing machines more useful to us, the superior humans, is a very good thing.

    New stuff! Less bugs! More bugs!

    Avoiding the obvious Shakespearean quandary over what version number to give this, here's what's new:

  • SWFTextField is.. a text field!

  • Browser-defined fonts. Super handy for text fields (see above).

  • Very cool action decompiler in the listswf util turns action bytecode into that c-like action script stuff I love so much (when it works).

  • Type 2 buttons rendered. This means you can do fancier action stuff. Check the examples for.. an example.

  • Some really stupid compiler stuff fixed, like simple increments actually work now. And setTarget, too.

    download version 0.0.2b

    PHP documentation

    Getting an error when you compile? Something about yyparse call not matching function prototype? See below.

    Actions! Buttons! Sprites! Morphs! New in version 0.0.2a!

    Actions are made from c-like script code with a swank little compiler- much, much faster than clicking through half a dozen menus and dialogs for every command you want. And there's plenty of exciting bugs to discover!

    Buttons are.. you know what buttons are: roll over 'em, click 'em. Now that's entertainment!

    Sprites (aka movie clips) are little movies inside your movie! Whoa!

    Morphs are those fancy twisting squiggles that are used in all the wrong places and make your computer crawl!

    download version 0.0.2a

    (note: ming-0.0.2a requires php-4.0.1. If you really want to compile with 4.0.0, look in the ming.c file in the php_ext directory- see down there at the bottom, that bit of code that's commented out? Uncomment it, and comment the bit below it. Very good.)

    Macromedia(r) and Flash(tm) are trademarks or registered trademarks of Macromedia, Inc. in the United States and/or other countries.

    Macromedia(r) does not sponsor, affiliate, or endorse this product and/or services. Nor does China.

    All content Copyright (C) 2000-2002 Opaque Industries except where noted otherwise.