NOTE: it seems some think I am asking the question "Should I use this code style?", but I am actually asking "How can I achieve this?". Sorry If my question is confusing.
To create an image with PHP you can use these kind of base functions:
http://php.net/manual/en/ref.image.php
But by default it seems rather static. Example:
/* file: PHPImage.php */
$img = imagecreatefrompng('logo.png');
// Do some stuff to that image
header('Content-type: image/png');
imagepng($img);
imagedestroy($img);
I would like to create a class that can manipulate images on the fly and pass it a function that can manipulate the $img
on a call back, and do all of that inline.. something like this:
<?php
$img = new PHPImage("baseimage.png", function(&$thisimg){
// Color functions here etc
});
?>
<img src="<?php echo $img->URLResource; ?>" />
I see that this is a feeble example but just wondering if this kind of workflow is possible.
What I'm wondering is: I get that you could pass GET parameters to a constant page setup for this eg. scripts/PHPImage.php?w=160&h=160&bgcol=255-0-0
, and then use the passed parameters to run the actual image functions on that page. But is there anyway you could use the actual functions on the image and generate it in a casual workflow, like my PHPImage class example above?
Thanks in advance for any help!