So I had this idea:
Since it seems many PHP installs have the GD library included by default, making thumbnailing easier (and uglier, I guess), I figured it would be nice if Wakaba could use this too so as not to be at a disadvantage to Futallaby when it comes to getting thumbnailing working properly.
So I figure it would be fairly simple to make a PHP script that takes as its arguments a local filename for an image, a local filename where to place the thumbnail, and the dimensions for the thumbnail. The wakaba make_thumbnail function could then in addition to all the other things it tries also try hitting this PHP script, through the web server if need be (command-line PHP isn't all that common, is it?).
However, I'm no PHP hacker, and I'm busy coding other things (just optimized the kareha templating functions enough that I could put them in wakaba), and thus I am asking if anyone feels they would be up to the task of writing this hack.
You'll have it by the end of the day.
Just to clarify... You want it to be a command-line script, right? Something that would work like..../phpresizer -w300 -h300 path/to/original.jpeg path/to/thumbnail.jpeg
You're right, command-line PHP scripts are quite uncommon, but possible. What ideas do you have for sending errors (original file not found, can't write to thumbnail directory, etc) back to Wakaba?
Well, the best would be for it to be able to work through the web server too, in case command-line PHP isn't available. And it doesn't really need to send any errors back, it's enough if the thumbnail file doesn't appear if it fails.
Okay, well, if it works through the web server, then you'll be redirecting the client's web browser from wakaba.pl
to resizer.php?path=/path/to/img.jpg
, right? Is that what you had in mind? Then what should the PHP script redirect the client to when it's done?
Doing it solely via the CLI will be a lot less messy, and faster as well...
http://www.anre.org/crap/tn.text works just dandily via the CLI.
If you still wanna try calling it through the web server, I can modify it to work that way too, but as I said, there's logistics we're gonna have to work out...
You'll notice the code, as it is now, outputs error messages prefixed with a two-digit number if something goes wrong (and also if something goes right). If you'd like, you can have your code read those two digits to tell what the problem was. For example, if it sees "13" as the first two digits, it can tell that the PHP script couldn't find the original file. "00" or "01" means all went well. Hope this helps.
I'll have a look at it as soon as I am done with some other stuff.
Anyway, I was thinking the Perl script could just open a connection to post 80 on localhost to trigger the script through the web server. It could then give the paramaters in the query string in the usual way.