Hello,
Recently I had to develop a website and the client I made it for, really wanted to have a lot of the content shown using “their” font. They wanted to be able to make new menu items and stuff like that, but have absolutely no idea how to work with a program like Photoshop.
To get this happening, I made a plugin called Renderer, which basically does one thing: it takes the text you enter between the plugin tags and renders it to a PNG image, using a TTF file to render the text.
The plugin uses the GD library and the PHP image functions to render the image. Besides that, it also uses a function (file_get_contents in combination with URLs) that is disabled by some hosting companies. So make sure you have both the GD library enabled and that file_get_contents is allowed to perform HTTP calls before even trying the plugin.
An example:
{exp:renderer:render font="arial" size="16" color="000000" bg="ffffff"}
The text you want rendered
{/exp:renderer:render}
This will show up as a PNG image as soon as you visit your site. The text will be rendered using the “color” value with its background transparent and the edges of the font using the bg color. Some sort of simple ‘anti-aliasing’, if you’d like.
As soon as the image has been created, it will be cached. This will obviously enhance the performance of your web server due to the fact that the PNG only needs to be rendered once. This behaviour can be disabled, if desired.
This plugin is definitely not in its final state and I would love any suggestions to progress its development.
You can find the plugin and more information/examples here:
http://ee.dev-hell.com/plugins/renderer
regards, Michiel.
Hey this sounds great! Well done!
I noticed that in your example image, the tag contains width and height values - is that something the plugin generates or did you add that later?
It would be nice if you could view the image directly, and ‘save image as’ instead of it showing up as a php file, but other than that, awesome!
Hey this sounds great! Well done! I noticed that in your example image, the tag contains width and height values - is that something the plugin generates or did you add that later? It would be nice if you could view the image directly, and ‘save image as’ instead of it showing up as a php file, but other than that, awesome!
Thanks for the kind words 😊 Great that you like it.
The width and height values are added by the plugin, but only if the server you’re hosting the EE site on has support for use file_get_contents with URLs (this is sometimes disabled by hosting companies). The addon will open the image file and determine its width and height. This will not work correctly the first time the image is generated (due to timing, usually only the height works the first time), but that’s not really a big problem.
I don’t know if I get what you mean with your last sentence, but it wouldn’t be that hard to make your browser save the image immediately. At this moment I just pass an image header, but if you also add a content-disposition header, you could make it so that generating the image triggers a “save file as” dialog.
If you have any more questions or suggestions, feel free to let me know about them.
Michiel.
Just for reference, there is a module (!) out there that essentially seems to be doing the same thing.
I think this is great!
One thing with this plugin (which is similar to my original first-draft module release) is that it exposes the system url. I took a lot of flack for it when I first put my module up, but I did have plans to expand it - I hastily wrote it during the 2nd half of the blogathon and was half-asleep…that’s my excuse and I’m sticking to it. 😉
My first run was exactly like this - where it used query strings on the generator script. But starting it out as a module made it easy for me go in and add more functionality and customizability (is that even a word?).
Anyway, I think this is great. My site is down and the module is unavailable (reinstalling ee), but I’ll put a link on my placeholder page to this thread for an alternative. 😊
Hey all,
As posted in the other thread, you might want to check out my module - it does the same thing, only uses a different text rendering engine that supports proper anti aliasing and it uses this to output a 24-bit PNG.
I’ve tried to use global variables with the plugin, but global variable names with underscores (_) aren’t allowed, so {global_variable} return {global_variable} or {global_variable} to be more specific.
When I remove urlencode() function in the line below, I does work, but is this a long-term solution? Does anybody know a better solution?
thanks
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.