RE: [PHP] ImageCreateFromJpeg()
| From: | Benton Jackson | Date: | Thu, 13 Jul 2000 15:35:01 +0000 |
| Subject: | RE: [PHP] ImageCreateFromJpeg() | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-6460@lists.php.net to get a copy of this message | ||
Nice. Or ghastly, depending on how Apache works. I don't know enough about
that.
If I open a file with HTTP through the local server, is it smart enough to
do it efficiently? If so, this would work nicely. If it has to go through
TCP/IP, I might as well write a temporary file.
> From: Jerry [mailto:jerry@acusd.edu]
>
> 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/
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
> For additional commands, e-mail: php-general-help@lists.php.net
> To contact the list administrators, e-mail: php-list-admin@lists.php.net