Image GD Wizardry!
| From: | Shane | Date: | Wed, 26 Jun 2002 22:48:50 +0000 |
| Subject: | Image GD Wizardry! | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-104072@lists.php.net to get a copy of this message | ||
One would think that pulling binary data from a DB using the function imageCreateFromString would
allow you to output that string to any format. (GIF JPEG PNG) or whatever is supported by your
version of GD.
But this code flakes out and creates no image if it reads from a binary file made by a GIF file.
(works great for JPEGs!!)
Anyone see what the problem might be? Or know of any way to output a JPEG or PNG from a binary GIF
file in a mySQL DB?
Theory code only...
1. Query binary string from DB
2. Create Image From String
3. Scale your image to fit the size you need.
4. Use ImageCreateTrueColor to create your compatible background square
5. Fill it with your background color using ImageFilledRectangle
6. Use ImageCopyResampled to place your Image from String onto you background image
7. use imageJpeg to output your true color image as a JPEG
Since this works great as JPEG IN, JPEG OUT, but does NOT work when GIF is the source, is this
because ImageCopyResampled can't use the GIF image?
If so, anyone have a nice code snippet that will turn client uploads from GIFs into JPEGS?
- Thanks in advance folks, I realize this is a tough one, and any suggestions are always greatly
appreciated, and as always I will post my final solution for the archives.
Thanks again.
-NorthBayShane