Inserting an image to MySql type BLOB from python and show from MySql to PHP -
i trying store image url database base64, when seek show in webpage based on php, doesn't work..
here's python code:
import urllib3, io, requests pil import image import base64 url = 'www....com/pic.jpg' img_conn = urllib3.connection_from_url('www....com/') img_file = img_conn.urlopen('get', url) image.seek(0) resized_image = image.open(image) resized_image.thumbnail((75,75), image.antialias resized_image = base64.b64encode(resized_image.tostring())
the resized_image
added database column called pic
type longblob.
my php code looks this:
$sql = "select pic product limit 1"; $stmt = $pdo->prepare($sql); $stmt->execute(); $row = $stmt->fetch(); $decoded_image = base64_decode($row['pic']); $formimage = imagecreatefromstring($decoded_image);
i message:
php warning: imagecreatefromstring(): info not in recognized format in /home/...
what doing wrong? there way save image url within database?
php python base64 pillow
No comments:
Post a Comment