tonyc's Journal http://use.perl.org/~tonyc/journal/ tonyc's use Perl Journal en-us use Perl; is Copyright 1998-2006, Chris Nandor. Stories, comments, journals, and other submissions posted on use Perl; are Copyright their respective owners. 2012-01-25T02:25:07+00:00 pudge pudge@perl.org Technology hourly 1 1970-01-01T00:00+00:00 tonyc's Journal http://use.perl.org/images/topics/useperl.gif http://use.perl.org/~tonyc/journal/ Imager file format modules http://use.perl.org/~tonyc/journal/39652?from=rss <p>I'm considering splitting out Imager's file support for those file types that require external libraries, in particular:</p><ul> <li>GIF</li><li>TIFF</li><li>JPEG</li><li>PNG</li></ul><p>Possibly also the font file handlers:</p><ul> <li>Freetype 1.x</li><li>Freetype 2.x</li><li>T1Lib</li><li>Win32</li></ul><p>Unlike the current Imager package these would fail to install unless the appropriate library could be found (or built), so your code could depend on Imager::File::GIF and be sure that GIF support was available, which isn't currently the case.</p><p>I'd produce file format distributions such as Imager-File-GIF at least six months before removing them from Imager itself. Installing such distributions would add (for example) GIF support to Imager if it wasn't already present, or be ignored if it was.</p><p>I'd also release Task::Imager which would depend on Imager and each of the file format support distributions needed to match the Imager </p><p>This allows:</p><ul> <li>just depend on Imager::Task to get the same file formats you get now (possibly some more)</li><li>depend on Imager::File::Foo to get the format you want and be sure they're present</li></ul><p>Reactions?</p><p>(I suspect this is going to be more painful for packagers than anyone else.)</p> tonyc 2009-09-21T03:25:04+00:00 journal Imager tiff support http://use.perl.org/~tonyc/journal/34999?from=rss <p>Imager's tiff support has been greatly extended to:</p><ul> <li>add support for large sample sizes, Imager can now read and write 16 and 32-bit/sample RGB and greyscale images and manipulate them.</li> <li>read and write bi-level images</li> <li>allow selection of the compression used for the image.</li> <li>work around some bugs in various versions of libtiff's RGBA image support, in particular alpha channel handling for grey and cmyk images.</li> </ul><p>This is a large change, so I've released Imager 0.61_02 as a test release. If you use Imager with TIFF much, please give it a go.</p><p>I'm planning on a 0.62 release in a week or so.</p> tonyc 2007-11-29T00:31:29+00:00 journal Imager security fix http://use.perl.org/~tonyc/journal/33153?from=rss <p>Imager 0.57 is a security fix release.</p><p>After following up on a <a href="http://www.securityfocus.com/archive/1/archive/1/464726/100/0/threaded">buqtraq message</a> describing BMP issues in some viewers I <a href="https://rt.cpan.org/Public/Bug/Display.html?id=26107">decided to test Imager</a> against the test images.</p><p>Unfortunately Imager failed on some of the test images.</p><p>Imager 0.57 corrects this.</p> tonyc 2007-04-30T09:11:29+00:00 journal Imager development release http://use.perl.org/~tonyc/journal/30241?from=rss <p>A new Imager development release 0.51_02 is now on CPAN.</p><p>This adds Windows Icon/Cursor file support, an interface for adding new file types, a new variant of flood_fill that fills to a given border color and the usual collection of other tweaks.</p><p>Please give it a go if you have a chance.</p><p>Something fairly similar to it will be released as 0.52 unless I see some problems reported.</p> tonyc 2006-07-10T14:17:11+00:00 journal Imager 0.51 released http://use.perl.org/~tonyc/journal/29448?from=rss <p> <a href="http://imager.perl.org/a/43.html">Imager has been released</a>, it fixes a few bugs.</p><p>For now work is keeping me busy, so the next feature release (file hooks, ICO support, Changes changed) is delayed for now.</p> tonyc 2006-04-26T03:35:34+00:00 journal Imager 0.48 pre-release http://use.perl.org/~tonyc/journal/28808?from=rss <p>I uploaded Imager 0.47_01 to CPAN last week as a pre-release to 0.48.</p><p>Imager 0.48 adds the API I mentioned last month, some other minor features and fixes.</p><p>If you get a chance to test it please let me know of any problems. If you're using the CPAN shell you can use:</p><blockquote><div><p> <code>test T/TO/TONYC/Imager-0.47_01.tar.gz</code></p></div> </blockquote> tonyc 2006-02-27T02:44:35+00:00 journal Imager API http://use.perl.org/~tonyc/journal/28395?from=rss <p>Over Christmas I made most of Imager's API, such as it is, available to external modules.</p><p>This has 2 purposes:</p><ul> <li>you can write XS modules that access Imager at the C level for speed. eg. the mandel dynfilt module that has been supplied with Imager for years, is now a perl/XS module installed as part of Imager.</li><li>you can write C level image or fill objects for Imager. eg. I have Imager::SDL in SVN at the moment, which renders whatever you draw to a SDL surface.</li></ul><p>I added a hook for Inline::C as well, which makes the API <i>very</i> easy to use, assuming C doesn't scare you too much.</p><p>Of course, none of this is released yet, but what's there hangs together.</p><p>Currently some of the API isn't exposed - file access, because it's not an image manipulation function, and fonts, because the C level font API is fairly chaotic.</p><p>Imager's release cycle has tended to be pretty long, but hopefully I'll get this out in the next few weeks.</p><p>Right now I'm going through the file handlers and checking they report errors correctly - in some cases the C level handlers do, but the perl level code is discarding the error &lt;sigh&gt;</p> tonyc 2006-01-18T06:31:53+00:00 journal Imager 0.45_02 http://use.perl.org/~tonyc/journal/27985?from=rss <p>I've uploaded a release candidate for Imager 0.46 to CPAN.</p><p>If you use Imager, please take the time to test it out, using CPAN shell this would be:</p><blockquote><div><p> <code>perl -MCPAN -eshell<br> <br> test T/TO/TONYC/Imager-0.45_02.tar.gz</code></p></div> </blockquote><p>The major changes in Imager 0.46 include:</p><ul> <li>EXIF support when reading JPEG images</li><li>you can read a given page of GIF or TIFF files</li><li>the read method now reads the first image of a GIF instead of consolidating them (the old behaviour is still available if needed)</li><li>you can limit the sizes of images read from files</li><li>significant documentation changes</li><li>many minor bug fixes</li></ul> tonyc 2005-12-14T22:35:28+00:00 journal Imager 0.45 (almost) http://use.perl.org/~tonyc/journal/24869?from=rss <p>A release candidate for Imager 0.45 is now on CPAN, though it may take a little while to get to some mirrors.</p><p>If you have time please try to run the test suite, the simplest way to do that is with the CPAN shell, if you've configured it:</p><blockquote><div><p> <code>perl -MCPAN -eshell<br> test T/TO/TONYC/Imager-0.44_01.tar.gz</code></p></div> </blockquote><p>If you see test failures on OS X 10.4 in t/t20fill.t, please send me a copy of the generated fills.o and the result of:</p><blockquote><div><p>gcc --version</p></div></blockquote><p>then try running:</p><blockquote><div><p>gcc_select 3</p></div></blockquote><p>and attempting to build/test Imager again. You can do:</p><blockquote><div><p>gcc_select 4</p></div></blockquote><p>to return to the default gcc 4.0 pre-release.</p> tonyc 2005-05-25T06:03:10+00:00 journal Imager and Apple's GCC 4.0 http://use.perl.org/~tonyc/journal/24727?from=rss <p>At this point I'm ready to put out a test release of Imager 0.45, but... 0.44 is <a href="http://www.nntp.perl.org/group/perl.cpan.testers/202802">failing tests under OS X 10.4.</a> </p><p>For a short time I had access to a 10.4 machine, and found that the pre-release of GCC 4.0 that Apple shipped with Tiger was generating incorrect code. When I build the released GCC 4.0 under OS X 10.3.9, and use that to build Imager, all tests pass.</p><p>To see the code in question, build Imager and run:</p><p> <code>otool -vt fills.o | less +/^_fill_hatch # on OS X</code> </p><p>At this point I'm wondering how to handle this.<nobr> <wbr></nobr>:</p><ul> <li>ship and be damned, take test failures from 10.4 testers, take test failures from people trying to install it, and live with it</li><li>attempt to workaround the two sections of code that I know have incorrect code generated, and hope no other code has the same problem.</li> <li>probe the compiler GCC version and don't allow building by default if it's the GCC that shipped with OS X 10.4 (the perl -V output indicates GCC 3.3, but 10.4 builds with a GCC 4.0 pre-release by default.)</li></ul><p>At the moment I'm inclined to go with the first option, but all the solutions have their problems.</p> tonyc 2005-05-17T04:44:17+00:00 journal New Imager http://use.perl.org/~tonyc/journal/22412?from=rss <p>I finally released Imager 0.44.</p><p>Now for 0.45...</p><p>I'm looking to:</p><ul> <li>improve the library probe mechanism - in particular to use freetype-config/pkg-config if it's available</li><li>audit some of the other built-in image file format code</li><li>add a cookbook (documentation), and</li><li>probably other clean-up along the way</li></ul><p>Doing this type of clean-up isn't the most exciting thing in the world, but I'd like to have a clean base to add new features to when I get around to it.</p> tonyc 2004-12-22T03:27:55+00:00 journal More Imager (finally) http://use.perl.org/~tonyc/journal/22218?from=rss <p>After way too long I've created an Imager 0.44 release candidate. This is available from CPAN as development release 0.43_03.</p><p>If you can, please run the Imager test suite. The simplest way to do this is with the CPAN shell:</p><p> &nbsp; &nbsp; perl -MCPAN -eshell<br> &nbsp; &nbsp; test T/TO/TONYC/Imager-0.43_03.tar.gz</p> tonyc 2004-12-08T23:40:50+00:00 journal UTF8 http://use.perl.org/~tonyc/journal/4314?from=rss <p>Of course, before I try to do any of the high level text output done, I want to try to make the feature set between Imager's various font drivers a bit more consistent.</p><p>Yesterday, only the Freetype2 driver had support for <a href="http://www.eecs.umich.edu/~addi/perl/Imager/docs/Font-pm.html#utf8">UTF8</a>, <a href="http://www.eecs.umich.edu/~addi/perl/Imager/docs/Font-pm.html#item_transform">transformations</a> and the <a href="http://www.eecs.umich.edu/~addi/perl/Imager/docs/Font-pm.html#item_has_chars">has_chars()</a> method.</p><p>I was all set to rebuild the Freetype 1.x driver's caching mechanism with something more complex (and probably more buggy) when Addi suggested a simpler implementation. Doh!</p><p>Hence the first step is done - the FT1.x driver has UTF8 support.</p><p>Now for the rest.</p> tonyc 2002-04-19T00:20:40+00:00 journal Drawing Text http://use.perl.org/~tonyc/journal/4280?from=rss <p>Arnar released <a href="http://www.eecs.umich.edu/~addi/perl/Imager/">Imager</a> <a href="http://testers.cpan.org/search?request=dist&amp;dist=Imager#0.40">0.40</a> last week, followed quickly by 0.41, since I hadn't tested the changes I'd made to the giflib tests <i>without</i> giflib. Oops.</p><p>But it's out the virtual door now. So what do we do for Imager 0.42?</p><p>One thing I've always found picky and annoying is laying out text, whether it's just aligning text around a point, or filling a box with it, and Imager doesn't make this any easier, since the <a href="http://www.eecs.umich.edu/~addi/perl/Imager/docs/Font-pm.html#item_bounding_box">bounding_box() method</a> simply returns a list of fairly basic information, which makes it difficult to read the code that uses it.</p><p>What I want to try to do is provide some tools to make it easy to do both simple tasks like aligning a line of text around a point, or in a box, and more complex tasks like filling a box with text, possibly including some way of handling richer text with face and font changes.</p><p>The ultimate result of all this would of course be <i>pod2Imager</i><nobr> <wbr></nobr>;).</p><p>Of course writing such tools at the perl level would require more access to glyph metrics, which could be useful to the masochists who want to do all the above themselves.</p><p>Now I just need to find the time to do all of this.</p> tonyc 2002-04-18T01:42:49+00:00 journal Time http://use.perl.org/~tonyc/journal/4278?from=rss <p>I rediscovered <a href="http://www.megatokyo.com/">MegaTokyo</a> yesterday. Listen to it suck my day away.</p><p>At least I've read the whole lot now, so it should only suck a few minutes away per day now.</p><p>.</p> tonyc 2002-04-18T01:12:38+00:00 journal Imager 0.40pre2 http://use.perl.org/~tonyc/journal/3900?from=rss <p>After a hectic Easter, there's an update to Imager0.40pre1 - pre2! This fixes all the bugs reported on <a href="http://rt.cpan.org/NoAuth/Bugs.html?Dist=Imager&amp;ShowAll=1">RT.cpan.org</a> and a few more:</p><ul> <li> <a href="%23broken_giflib">Broken versions of giflib</a> are now reported to the user more obviously.</li> <li>grayscale images are now quantized correctly</li> <li>better OS X support, since some of Imager's exported symbols were causing conflicts with some perl builds</li> <li>$img-&gt;box(fill=&gt;...) was going into an infinite loop on non-8bit/sample images or where the fill only provides a double interface</li> </ul><p>You can download pre2 from the <a href="http://www.eecs.umich.edu/~addi/perl/Imager/devel/">Imager development page</a>.</p><p>* Any unpatched 4.1.0<nobr> <wbr></nobr>:)</p> tonyc 2002-04-01T15:06:24+00:00 journal More GIF http://use.perl.org/~tonyc/journal/3372?from=rss <p>It's been a while since I wrote anything here.</p><p>Over the last few weeks I rewrote the GIF writer to avoid the GIF specific options handling, and to use tags instead. I also added some compatibility code to convert the older parameters (warning by default.)</p><p>Beyond this Imager has had a lot of work done on it since October, including a bunch of bug fixes, a reorganization of the documentation, which will hopefully make it less unwieldly, and support for Mac OSX.</p><p>Addi's considering releasing 0.40 soon, so if you're reading this please pull down Imager CVS and give it a go<nobr> <wbr></nobr>:)</p> tonyc 2002-03-08T05:03:44+00:00 journal Arrgh http://use.perl.org/~tonyc/journal/1099?from=rss <p>I still need to create a demo for image based fills. Sigh.</p> tonyc 2001-10-29T01:44:53+00:00 journal Imager 0.39pre1 http://use.perl.org/~tonyc/journal/1097?from=rss <p>I've been very busy with work over the last few weeks, and finally I'm working sane hours again. I hope.</p><p>Addi's planning on releasing 0.39 of <a href="http://www.eecs.umich.edu/~addi/perl/Imager/">Imager</a> to CPAN soon, and so has released <a href="http://www.eecs.umich.edu/~addi/perl/Imager/devel/Imager-0.39pre1.tar.gz">0.39pre1</a> for testing by anyone who's interested.</p><p>This means that all the funky new features that have been added since 0.38 will soon be available on CPAN.</p><p>Some of these include:</p><ul> <li>Freetype 2 support, with transformations (rotation, shearing)</li> <li>fountain fill filter (supports most of the functionality of the gradient tool in the GIMP)</li> <li>general fills, including hatched, fountain (gradient), tiled images (with transformations), transparent colored fills. These can be used on boxes, filled arcs, and flood fills.</li> <li>masked images, so you can take a rectangular subset of an image, and even supply a write mask</li> <li>improved gif support (better handling of paletted images)</li> <li>reading and writing Windows BMP and TARGA files</li> <li>image tags, use to store meta-data read from an image, most formats support resolution information, some support more</li> <li>image rotation (you needed to mess around with the transform2() engine before this). The same engine can do other linear transformations.</li> <li>more ways of specifying a color, in Imager::Color-&gt;new</li> <li>exposed some filters that didn't appear in the OO interface</li> <li>image sharpening, either through the unsharp_mask filter or using the convolution filter</li> <li>better Win32 support, under both normal Win32 and cygwin</li> <li>lots of bug fixes</li> </ul> tonyc 2001-10-29T00:33:46+00:00 journal Imager::Graph http://use.perl.org/~tonyc/journal/897?from=rss <p>Well, I finally released <a href="http://www.develop-help.com/imager/graph/">Imager::Graph</a>. It only has <a href="http://www.develop-help.com/imager/graph/piegraph.html">pie graph support</a> but it shouldn't be too hard to add other graphs as time goes by.</p><p>I can already see improvements I want to make to it, but the current version (0.02) produces a fairly nice pie graph, and has plenty of knobs to tweak.</p> tonyc 2001-10-06T13:38:09+00:00 journal Minor stuff and pie graphs http://use.perl.org/~tonyc/journal/812?from=rss <p>Over the last week I:</p><ol> <li>changed the GIF code to write paletted images efficiently, where possible</li> <li>implemented image based fills</li> <li>implemented a simple unsharp mask</li> <li>change the convolution filter to clamp at low sample values</li> </ol><p>With the last two, Imager can finally reliably sharpen images, see the <a href="http://www.develop-help.com/imager/filters.html">filters examples page</a> for details, the <a href="http://www.develop-help.com/imager/filters/vab_convsharp.jpg">convsharp</a> and <a href="http://www.develop-help.com/imager/filters/vab_unsharpmask.jpg">unsharpmask</a> examples in particular.</p><p>I also started work on Imager::Graph, the base class of a set of modules meant for creating graphs of various types, starting with <a href="http://www.develop-help.com/imager/graph/piegraph.html">pie graphs</a>.</p><p>The aim is to have Imager::Graph abstract the way the graphs look, colors, font sizes, positioning, element sizes and so on. All of this can be customized by the user, but they can get good results quickly. Since the basic looks are all controlled by Imager::Graph, Imager::Graph::Bar can use those same styles, to produce a graph that matches the pie chart produced by Imager::Graph::Pie.</p> tonyc 2001-09-23T03:07:15+00:00 journal Bugs http://use.perl.org/~tonyc/journal/797?from=rss <p>I fixed a couple of bugs over the last few days.</p><p>Writing text with the tt (Freetype 1.x) driver would give chop off the left of the first character if it overlapped the left of the start of the text output, and the widths of the bounding box pre-added the the left overlap - breaking the bounding box calculations.</p><p>The C level code to write jpeg images wasn't doing any error reporting, now it does.</p><p>Next I'm going to do something I really &lt;sarcasm&gt;love&lt;/sarcasm&gt; - modify the GIF writer to handle paletted images. Currently if you pass a paletted image to the GIF writer it tries to build a palette and re-quantize the image. This is very, very slow.</p> tonyc 2001-09-16T02:44:31+00:00 journal A Demo http://use.perl.org/~tonyc/journal/780?from=rss <p> <a href="http://www.develop-help.com/imager/combines.html">http://www.develop-help.com/imager/combines.html</a> </p> tonyc 2001-09-10T13:10:03+00:00 journal More Fills http://use.perl.org/~tonyc/journal/777?from=rss <p>I finally finished adding combining fills.</p><p>Except for the two basic cases, 'none', which simply replaces the target, and 'normal', which uses the alpha channel to weight the fill, I suspect they're mostly useful for special effects.</p><p>For example, if you wanted to turn an image into a rainbow, preserving the brightness, you could use the 'color' mode, which replaces the hue and saturation of the target pixel with that of the fill pixel.</p><p>I'll put a demo up soon.</p> tonyc 2001-09-10T00:38:35+00:00 journal Fills http://use.perl.org/~tonyc/journal/734?from=rss <p>On Friday my time, <a href="http://simon-cozens.org/">lathos</a> asked about doing hatched fills in <a href="http://www.eecs.umich.edu/~addi/perl/Imager/">Imager</a>.</p><p>So I implemented <a href="http://www.develop-help.com/imager/hatches.html">hatched fills</a>.</p><p>Rather than just implementing hatched versions of the current <i>i_box_filled()</i> and <i>i_arc()</i> functions I created a new Imager object - a fill object. These can currently be used with arcs, boxes and the flood fill, which <a href="http://www.eecs.umich.edu/~addi/">Addi</a> had implemented, but hadn't written an OO interface for.</p><p>So now we have hatched fills, I also added a solid fill object (which could merge alpha values), and took the fountain fill code to build a fountain fill. So now you can flood fill with a fountain (or gradient) fill </p><p>Today I realized the combine option could have been more powerful - currently it's just a flag, either to replace the current color, or to do basic alpha merging. When I get time (soon, I hope), I'll implement some of the types of merging you get from software like the <a href="http://www.gimp.org/">GIMP</a>, such as addition, hue only, value only, and so on.</p> tonyc 2001-09-03T06:30:25+00:00 journal Fountain fills and JPEG http://use.perl.org/~tonyc/journal/687?from=rss <p>Over the weekend I managed to implement most of the fountain (or gradient) fill code I wanted. So I wanted to be able to load GIMP Gradient files - and found a bunch of new features I'd have to add to support them. So I will. Eventually.</p><p>Last night I was trying to get my <a href="http://www.develop-help.com/imager/filters.html">filters example page</a> to work with JPEG files instead of PNG files - and bumped into a few JPEG bugs. First was a screwup left over from the exp_represent merge - the code to call i_writejpeg() had migrated up into Imager::read()! <i>D'oh!</i> </p><p>Second was a problem in the IO layer translation code, now fixed.</p><p>Now I just need to figure out why the <a href="http://www.develop-help.com/imager/xform.mhtml">transform2 demo</a> isn't working. <i>&lt;sigh&gt;</i> </p> tonyc 2001-08-22T01:19:54+00:00 journal BMP and Fountain Fills http://use.perl.org/~tonyc/journal/672?from=rss <p>I started adding support for working with Windows BMP files, writing was easy enough (since I haven't bothered with compression - yet), but the reading is proving a pain, since I think (de)compression is needed. Maybe I'm just lazy.</p><p>One thing I'm used to from The GIMP and other paint software is fountain fills. Currently the closest Imager has to that is Addi's gradient filter, which is very different to a normal fountain fill. My only problem with trying to write fountain fill code is that my math is a bit rusty.</p><p>I just need to kick those brain cells into submission, I suppose.</p> tonyc 2001-08-17T00:38:13+00:00 journal Bugs-- http://use.perl.org/~tonyc/journal/663?from=rss <p>I finally got around to merging the Imager exp_represent branch with the main branch. The only problem was some files that had large modifications in both branches - CVS well and truly messed them up, only to be expected I suppose. I hand merged them, fixed up the test numbers that has been broken by the merge, since new tests had been added on both branches, and it all worked.</p><p>Well almost.</p><p>I've discussed adding some sample code to the distribution with Addi, since Imager is getting pretty difficult for a new user to get their mind around.</p><p>So I started working based on a simple text to image to web application I wrote as a basic demo. Unfortunately it had several problems with handling fonts that have negative left-side bearings on the first character (where the left size of the glyph is to the left of the start point.) Found and fixed for freetyp2.c. Just need to figure out the clipping problems in the Freetype 1.x support code.</p> tonyc 2001-08-15T01:06:40+00:00 journal TIFF resolution http://use.perl.org/~tonyc/journal/653?from=rss <p>Now you can set the resolution of a TIFF image:</p><ul> <li><tt># 300 dpi image<br> $img-&gt;addtag(name=&gt;"i_xres", value=&gt;300);<br> $img-&gt;write(file=&gt;'foo.tif'); </tt></li> </ul> tonyc 2001-08-12T10:51:37+00:00 journal Fonts and Colou?rs http://use.perl.org/~tonyc/journal/652?from=rss <p>I finally got around to fixing writing text to a channel with freetype2. Then I added UTF8 support.</p><p>Back in May Mike Depot suggested that the Imager::Color class was inconsistent with the other Imager classes since it didn't take named parameters. I finally got around to fixing that. You can now use named parameters to do things that you had to write your own code for with Image:</p><ul> <li><tt># just plain RGB<br> my $rgb = Imager::Color-&gt;new(red=&gt;100, blue=&amp;gt200, green=&gt;255);<br> # HSV (converted to RGB internally)<br> my $hsv = Imager::Color-&gt;new(h=&gt;120, s=&gt;1, v=&gt;1);<br> # lookup a name in a GIMP palette<br> my $gimp = Imager::Color-&gt;new(gimp=&gt;$name); </tt></li> </ul> tonyc 2001-08-12T04:26:54+00:00 journal