Hi,
Been trying to find a way of inserting an uploaded image into a database. The image is resized before being put into the sql database.
What I need is some way to convert the image to a string (bascially the reverse of imagecreatefromstring()). Any ideas?
Getting string from image
Moderator: General Moderators
- MathewByrne
- Forum Commoner
- Posts: 38
- Joined: Sat Mar 27, 2004 9:49 pm
- Location: Australia
- MathewByrne
- Forum Commoner
- Posts: 38
- Joined: Sat Mar 27, 2004 9:49 pm
- Location: Australia
- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
There is no such function. You have to output the image data via one of the output streams such as imagepng(). You can, however, capture the output via output buffering (ob_start())
The reason you can't go right from image resource to a string is because strictly speaking, the data of an image resource isn't a picture. When you call imagejpeg(), for example, GD converts the binary data of the image resource into the format of a JPEG file. If you go right from an image resource to a string, you're just gonna get a garbled mess.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.