Jump to content
  • entries
    10
  • comment
    1
  • views
    13,436

WebGUI says goodbye to Image::Magick


scrottie

1,163 views

One request we've had for years is to put WebGUI on CPAN, but we always reached the conclusion that we had to get rid of Image::Magick first. I think the discussion went along the lines of, yes, we could put it on CPAN, and we want to, but first we need to get rid of Image::Magick.

For many years, virtually all WebGUI installs were on top of the WRE (WebGUI Runtime Environment), a pre-built binary self-contained Apache, MySQL, perl, mod_perl, etc environment for Linux. A tree of etc, usr, bin, etc directories lived under /data/wre. This is how pesky system dependencies were handled. The WRE contained the Image::Magick perl module, correctly configured, built, and linked against the correct version of the system ImageMagick library.

Having a pre-configured system like that was a huge boon for users who got up and running quickly, but it presents problems if you're already have a web server or proxy running on port 80, or you're already running mysql. It also took considerable resources to maintain against new versions of various Linux distros and to patch.

For as tricky as it can be to configure mod_perl, it turns out that setting up Image::Magick is far more difficult. This is the point where most people seemed to fail on the source install instructions. Getting it to work requires having precisely matching versions of the system library and Perl module, and even then, it's finicky and fragile. The API changed constantly, it regressed constantly, and, in general, defensive programming doesn't seem to be a priority.

The concern about putting it on CPAN was that there were too many dependencies, Image::Magick not the least of them. Someone pulling the code from CPAN would still have to go through the entire Source Install process: http://www.webgui.org/wiki/source-install Frankly, we wanted to encourage people to just use the WRE. Besides, we said, wG is on github, and has been for ages.

Previous work on wG8 removed Apache/mod_perl as a dependency. Running on plack, it's much closer to a stand-alone Perl application.

Graham (haarg) started the work of migrating away from Image::Magick. I just got tests passing again.

WebGUI::Storage knows how to thumbnail things. That's used by photo galleries and file uploads in general which may be attachments to various things. wG also generates its own captchas. Graham's work started there. He picked Imager, which is an XS module, bundling the C code with the Perl together in the CPAN distribution. I continued with that, mostly.

Besides getting tests passing again, the larger part of this was the Poll asset, which has three different flavors of image based plots it'll generate: a pie chart, a line graph (I'm not sure what the point is of this one, honestly; I guess it makes sense if the poll's questions represent contiguous values), and a bar chart.

Here's more information on the Poll asset from the WebGUI Content Manager's Guide: http://www.webgui.org/content-managers-guide-wiki/poll

wG's pie charts were really pretty in 7. Check out the pictures in there. Line and bar charts translated pretty directly from Image::Magick to Imager, but I'm punting on the pie charts. Image::Magick takes SVG Path syntax strings for describing fancy arcs, lines, and so on. Imager doesn't know how to plot a proper arc, only sections of circles. My attempt at translating pie charts resulted in something pretty... special.

WebGUI::Image::Graph::Pie is now implemented on top of GD::Graph::pie, which look like the examples in https://www.safaribooksonline.com/library/view/perl-graphics-programming/9781449358280/ch04s01.html GD is at least an optional dependency now, only required if you want pie charts.

I'm hoping that someone wants to fix up wG7's pie chart logic and releasing it as a stand-alone Perl module that does not depend on Image::Magick.

As for packaging, there have been a lot of requests for a Docker container, and that's something I hope to look into. The main direction I took was a semi-portable installer script based on xdanger's old installer script for Debian: https://raw.githubusercontent.com/AlliumCepa/webgui/master/installer/webgui_installer.pl

Most of the automated failure reports I've been getting from webgui_installer.pl have been... yup, Image::Magick failing to build. Doug, Colin, and the crew were right from the start.

This still leaves MySQL as a dependency, but I feel like we're within the realm of WebGUI being a reasonable Perl module. SQLite support would be nifty, but I have no plans to veer into yet another internals rework project without really good reason, and wG performance is largely limited by database performance, so the marriage to MySQL is mostly beneficial (even though some of us like Postgres a lot better).

Here's the bug ticket for replacing Image::Magick: http://www.webgui.org/community/webgui-8/issues/11849

As a footnote, I've also gotten automated install failure messages about Imager::File::PNG not installing cleanly. If I have work-around that, I swear I'm translating the C in Imager to Perl and making an Imager::PP. Or perhaps we need a perlcc to automatically compiled C to Perl, joining the ranks of a2p (awk-to-perl) in Valhalla.

Footnote 2: The Poll asset unit test was using the API incorrectly, and never actually registered any votes in the poll. When it went to plot things, it created empty plots. And no one noticed, until now.

0 Comments


Recommended Comments

There are no comments to display.

Guest
Add a comment...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...