Speed up... - Blog - Open Source - schlitt.info

schlitt.info - php, photography and private stuff

Speed up...

Image_Text 0.3 released (Due to a wrong copied example, I had to throw 0.3pl1 directly after that.)

As some of you out there might have noticed, I released a new version of Image_Text yesterday. This (still alpha rated) version 0.3 will follow another one in alpha stadium in the next days/weeks. Image_Text has been more or less completely rewriten since version 0.2 and implements major imporvements.

As there is first a huge performance improvement.

Pierre Alan Joye gave me a great bunch of hints shortly after release 0.2 was out, for which I now found time to implement them. Some little dirty performance tests showed up amazing speed imropvements. E.g. I tested to render a 300x300 pixel image with a simple, short text and let determine Image_Text a fitting font size between 2 and 20 pixel. The verion 0.2 took about 0.1 second to do. The new one takes about 0.005 sec. to. :) I hope to get some more benchmarks done after the PaWS.

For performance reasons I completely dropped the subclass Image_Text_Line.

The lines are now handled directly in an array. As I had to screw up the whole API I used the chance and unified it a bit. Sorry, for people using Image_Graph. I will work out a fix for that this evening and Stefan will hopefully release a new RC for that.

Rotations are now more comfortable.

Since I added the possibility to position a text box inside an image using the coordinates of it's center point. This allows you let the text box "stay where it is", if you use rotations.

You can download the actualst version of Image_Text as usually through the PEAR website or directly using the PEAR installer: "pear upgrade image_text".

The newly included example file allows you to test the functionality of Image_Text instantly inside the browser (using GET parameter).

Find the following resources on Image_Text here, too:

API documentation Source Example online

This link generates you (by standard) a textbox (300x300) in the center of a 600x600 pixel sized image with a randomly choosen text. You can tweak this script using simple GET paramters. As this example uses the new introduced center point positioning, rotations will be done around the center point of the box.

Find an overview how you can tweak this example here.

  • text You can let the script choose a random text or define the text with IDs from 0 to 4. 0 is the shortest text and 4 the longest one. Example.

  • font_size You can define a font_size greater 1. If you do not specify a font_size, the text will be autoMeaurized. Example.

  • line_spacing The line spacing can be defined in a multiplicator for the standard line space (1 line height). Example.

  • halign The horizontal alignment can be defined using the strings 'left', 'center' and 'right' (standard is left). Example.

  • valign The vertical alignment can be defined using the strings 'top', 'middle' and 'bottom'. Example.

  • angle Defines the angle for a optional rotation. This is standard 0 and you can set a degrees value for it. Example.

If you liked this blog post or learned something, please consider using flattr to contribute back: .



Add new comment

Fields with bold names are mandatory.