See also
FBInk, which may help achieving your end goal in a somewhat more efficient manner
.
Because let me tell you that otherwise, doing that in the most roundabout way possible is
fantastically inefficient . (Don't use that, it's freakishly terrible
).
(My IM builds are fairly standalone-ish, but that -ish may matter here: zlib & libpng are dynamically linked, and it expects to find them in the usual ScreenSavers hack paths. Plus, IM itself expects to find some support files in a few circumstances, which, again, are setup for the ScreenSavers hack).
FBInk is completely standalone, on the other hand.
That still holds true for LuaJIT & Go bindings. Python is a tad bit more complex, but in the greater context of my Python package, it also works in a standalone-ish manner
.