Re: ImageCreateFromJpeg()
| From: | Jerry | Date: | Thu, 13 Jul 2000 15:12:30 +0000 |
| Subject: | Re: ImageCreateFromJpeg() | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-6457@lists.php.net to get a copy of this message | ||
In article <NBBBKILNGOGFJHHNNLADMECBEKAA.goatrider@goatrider.com>,
goatrider@goatrider.com ("Benton Jackson") wrote:
> I have an image file that's in a database, how can I read it into an
> Image?
> I could write it to a file first, and then do "ImageCreateFromJpeg", but
> the
> whole point of this exercise is to avoid writing files.
By default, ImageCreateFromxxx only works on files and URLs. It should
be relatively easy, if you are familiar with C, to make it work on
strings.
However, a work-around would be to create it from a URL.
<?php
header("Content-type: image/jpg");
if ($Image) {
//we want to modify the image
$requiredImage = URLEncode($Image);
$theImage = ImageCreateFromJPEG("$PHP_SELF?Raw=$requiredImage");
list($copyowner,$left,$bottom) = getInfoFromDB($Image);
imagettftext ($theImage, 12, 0, $left,$bottom, $Black, "/fonts/Courier.ttf",
"Copyright 1963 $copyowner")
ImageJPEG($theImage);
} elseif ($Raw) {
//we are requesting the image raw from the database
$theImage = getImageFromDB($Raw);
echo $theImage;
} else {
//we don't know what we're doing
$theImage = createWarningIMG("Huh?");
ImageJPEG($theImage);
}
?>
http://www.bloodandgore.com/Images.php3?Image=Zapruder
should return the image as a modified JPG file (if bloodandgore.com
were running this script, which they aren't).
Note that getInfoFromDB, getImageFromDB, and createWarningIMG are
functions you'd have to create from your own knowledge of your
database.
Jerry
http://www.hoboes.com/jerry/