Support on Windows

After several nights of hair pulling, Windows support is there, as well as support for yet another notation: Philip’s Music Writer.

Let me talk about Windows support first. It took me way too much time to finish it than I anticipated. There are a couple of scaring problems for using PHP on Windows.

Command execution on Windows

Under PHP documentation of system() function, people have been talking about PHP incapable of executing any command line with more than 2 double quotes, since PHP 4.3.x. So the following command line:

"C:\Program Files\ImageMagick\convert.exe" "C:\Temp Folder\1.gif" C:\1.png

Produces an instant failure (because there are 4 double quotes). And adding insult to injury: it’s not limited to system(), any other program execution functions like exec(), popen() are affected as well. Now the newest stable version is 5.2.6, guess what? Nothing changed. And people simply invented schemes to circumvent the bug, the most obvious one being using batch file, and that’s what I end up doing as well.

tempnam() stupidity on Windows

So this is an undocumented feature: tempnam() on Windows only uses 3 letter prefix and a sequentially increasing counter as suffix! Now compare with the Unix counterpart — people have been complaining how this temp file creation is a security problem on Unix, but it’s suddenly not a security problem anymore on Windows! Fantastic!

Other people have been bragging programmers not to invent their own schemes, and use native functions instead. But no way, I won’t listen to such “recommendations”!


For Philip’s Music Writer support, it is also not as straight forward as it should be, the main problem being on image conversion. No matter how I indicated sheet size in PMW source, ImageMagick invariably insists image size is 612×792 (which translates to 8.5" × 11" under 72 DPI)! And the final resulting PNG file is a 1×1 pixel dot.

Probably the problem is on PMW’s side. Normally within PostScript preamble part there is at least a declaration of %%BoundingBox, specifying its size (some even go as far as specifying %%DocumentPaperSizes and %%HiResBoundingBox); yet nothing like that exists in PostScripts produced by PMW. Anyway, that problem is temporarily fixed by forcing paper size using ImageMagick -page option.

Leave a Reply

Powered by WP Hashcash