Closed (fixed)
Project:
ImageCache Actions
Version:
5.x-2.0
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
31 May 2008 at 01:25 UTC
Updated:
23 Nov 2008 at 13:21 UTC
Currently to write dynamic text to an image would require someone to write their own plugin/action. Would it be possible to add an optional box for php code (that was handed the image name) so users could insert their own code to produce dynamic text?
Comments
Comment #1
dman commenteda long while ago I had string-passing built into an earlier version .. but I wasn't happy with the interface, the parameter passing or the filenames it ended up creating.
And dopry wasn't keen on the processing problems.
Although you can try this - it's certainly a different job, so deserves its own little imagecache action process. Possibly called 'caption'? Although I can se it being leveraged for imagebuttons maybe, or maybe banner.module is a better place to start. Either way it's brand new code.
The big issue is that under the imagecache paradigm, calling one image with two different arguments would be expected to create two different cached derivatives. It also means that you need to know the argument again next time you try to retrieve the file.
OTOH, if you think that it should always just return the one image with whatever the string was when it was built, that's different code.
Plus - where does this dynamic string come from? Imagecache is usually invoked only as a request for a filename.
So there are some issues to be solved there.
None of them are impossible, but I'd only like to figure out the general-case fix-all solution, and the UI, error-checking and docs that go with it.
However,
If you have a very specific custom requirement in mind, perhaps you can do it in some custom code that just does one job well. It can probably be done in one page of code - whereas building a customizable one could be a dozen.
Comment #2
patrickharris commentedI hacked the old imagecache to add centered horizontal and vertical text to an image ... have a look here. With the unique image filename I can grab whatever info I need from the node the various images came from. Even though in this case the little thumbnails are jpegs, the text doesn't look so shoddy, and I think this would be a useful imagecache2 action/plugin. I'll try writing this as a 'caption' plugin.
Comment #3
patrickharris commentedI think I've got the 'captions' module working for dynamic text, at least for 0 degrees. At 90 degrees it's a few pixels off - I'll try & fix this. It also supports left+20 or center-30 etc & transparency. You can download it here. If you get a chance to look at it, let me know what you think.
Comment #4
marqpdx commentedthis is so exactly what i need.
i am having people buy tickets for an event. i want to take a base image and then personalize it with dynamic info (number of people etc...).
i have enabled this module (the gv_caption) but can't figure how to use it. please do advise. this seems like such a hugely key imagecache feature!
thanks,
m
Comment #5
patrickharris commentedHi marqpdx - do you have imagecache actions installed, as well as imagecache? This module was designed to work with imagecache actions, but seeing the author isn't interested, I might try & get it included in imagecache for Drupal 6.
Comment #6
dman commentedimagecache provides a hook for any modules to supply their own processes.
Imagecache_actions uses that hook to provide a small collection of color processes and an small collection of layer processes.
If you want to add a few text processes, that can be done in a very small module, just like the imagecache_actions ones do. It doesn't need to be bundled with either. But you can add it to imagecache_actions as a stand-alone module if it works, just to keep the library in one place.
Comment #7
patrickharris commentedThanks for that dman - I can't quite remember, but I'm fairly certain that my 'caption' module relied upon some of the functions in your _actions module. Next time I'll write it as a stand alone module.
Comment #8
dman commentedOK, I went through that code you provided.
I've pasted it together (not the most elegantly) into a new imagecache_textactions.module which contains both the static and dynamic text overlays.
They are now living uncomfortably alongside each other - the branched code should be re-merged somehow, or the 'text' action should be compressed back into one that just has an input-format type selector to switch between static and evaluated code.
I also feel that the PHP evaluation should work on print(), not return values ... but it currently works, so I'll leave it.
New release up at
http://drupal.org/node/297191
I hope I didn't break anything in the process.
Comment #9
patrickharris commentedThat's great - I hope someone finds it useful!
Comment #10
Anonymous (not verified) commentedAutomatically closed -- issue fixed for two weeks with no activity.
Comment #11
crea commentedPlease correct me if im wrong, but I dont see any option about dynamic text rendering in 5.x-2.0 release
Are you sure you merged the code ?
Comment #12
dman commented:-(
Looks like you are right.
I'd been doing it on the D6 branch
Which by the way was available - but didn't even show the -dev branch because there was no version 0 release :-(
Man I suck at CVS.
OK, so I copied it all back. A DRUPAL-5--2-2 release is rolling.
I've called it a release because it works for me BUT gets very snotty if it cannot find the font files it expects.
Any hints on getting a list of available system fonts on all platforms would be helpful.
Sorry all. Go break this one!
Comment #13
crea commentedAbout fonts: Most difficult thing about them is license. You can just include some font with free license in module distribution. Adding more fonts was always and will be host owner's duty. And I think there is no such thing as "available system fonts on all platforms" ( there are lot free fonts out there but they are not present in most systems by default )
Comment #14
dman commentedI know that there's no sure way to pick a font that will work for everyone, that's not what I mean.
What I was hoping for was that the OS or GD could TELL me what fonts there are to choose from so I could validate that it was available before I tried to use it!
As it it now, you have to enter the technical name for it, which is not the same as the display name, or the full path to the ttf file - which was damn hard to find out on a hosted machine.
My test machine has at least 40 fonts available, and they work if you know what they are called, but PHP doesn't.
It's true the only sure way will be for a user to provide their own - that's probably important to them anyway - and that's fine for step 2, but I hoped to get it working on first install. :-/
I guess I will just pick one for a distro. It just felt so messy.
Comment #15
gooddesignusa commentedIs there anyway to change the text spacing on the outputted text? Every letter seems a little close. I've tried a couple different fonts with no real change in spacing.
Thanks
Comment #16
dman commentedLooks pretty tricky
http://nz2.php.net/manual/en/function.imagettftext.php#74949
http://nz2.php.net/manual/en/function.imagettftext.php#60547
Not something I want to hack in by default, although it could be an option
Comment #17
gooddesignusa commentedwow thanks a lot dman. I had a lot of problems with the dynamic text to work correctly using the $caption['title']. I looked into the db and didn't see image_cache_fields. So i think its another problem not the textactions.inc file.
I ended up having to do some hackin to get what i want. I'm still very new to drupal but I got it to work.
This site is the one its going to be used on to dynamically make the text and roate it / overlay it on-top of the "spotlight" images. You will see if you go there.
http://www.gooddesignusanews.com/NAT_drupal/
The web version that was just finished last week. and is now getting drupal-ified.
www.natheatrix.com
thanks again for the links
Comment #18
patrickharris commentedI didn't have a problem with letter spacing, either at small or large sizes ... maybe I just lucked out with the fonts I was using? Or perhaps I'm not fussy :)
Comment #19
gooddesignusa commentedwhat fonts are you using? I've tried a couple. Arial, Arial Bold and some others
Comment #20
dman commentedI'm distributing a 'Liberation' GPL font in the D6 distro. Hopefully that will mean you can get results right away without having to go searching your system paths etc. You can probably back-port all the actions directly to 5.x with no changes.