Is this possible with php and a mysql database to Convert a blob into an image file?
相关问题
- Views base64 encoded blob in HTML with PHP
- Laravel Option Select - Default Issue
- How to get the background from multiple images by
- PHP Recursively File Folder Scan Sorted by Modific
- Can php detect if javascript is on or not?
If the BLOB contains the binary data of an image (in a recognizable format like e.g. tiff, png, jpeg, etc), take the content of the BLOB, write it to a file, and voilà... you got an image.
On some strange operation systems you have to give the output file a correspondig extension, so that the image file can be recognised as such.
In my case i had to use base64_decode to convert blob images correctly into file.
If you are storing images in MySql table Blob field and want to get these images then this article is useful for you:
Look at the following part from above article:
You can use a few different methods depending on what php image library you have installed. Here's a few examples.
Note, the echo <img> is just a trick I use to display multiple images from the same php script when looping through a MySQL result resource. You could just as well output via header() as @NAVEED had shown.
GD:
ImageMagick (iMagick):
GraphicsMagick (gMagick):