Images in databases

Want to move your code and projects to LiveCode but don't know where to start?

Moderators: Klaus, FourthWorld, heatherlaine, robinmiller

Post Reply
dpalmersce@gmail.com
Posts: 25
Joined: Wed Aug 28, 2019 4:58 pm

Images in databases

Post by dpalmersce@gmail.com » Sun Sep 08, 2019 9:25 pm

What is the best way to get an image converted to binary in order to store it in a database. I tried taking and getting the image data of an image and then converting it to binary but it got really slow and I know it shouldn't be doing that. I'm using livecode 9 on a Mac with a SQL database. To convert the image data 2 binary I was using binary decode thanks for any help

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 5155
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

Re: Images in databases

Post by jacque » Mon Sep 09, 2019 3:41 pm

Images are already binary, they don't need conversion.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

dpalmersce@gmail.com
Posts: 25
Joined: Wed Aug 28, 2019 4:58 pm

Re: Images in databases

Post by dpalmersce@gmail.com » Mon Sep 09, 2019 4:46 pm

I do understand that they are binary but when I try to store them in a variable to send to my database it won't send it and when I look at what is being sent on message it just puts the number 1. So what would be the best way to do this?

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 5155
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

Re: Images in databases

Post by jacque » Tue Sep 10, 2019 4:31 pm

I'm not the right person to ask about database interactions but I'm pretty sure this has been discussed here in the past. Did you try searching the forums for "images in databases" or variations of that? I seem to remember the word "blob" is involved.

I do so little work with databases but lots of others here do.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

bogs
Posts: 3999
Joined: Sat Feb 25, 2017 10:45 pm

Re: Images in databases

Post by bogs » Tue Sep 10, 2019 4:49 pm

Well, I know it is a popular topic not just here, but all over. And I used to put images in dbs myself, but I've started not doing that recently. A fairly good discussion on it can be found here.

However, assuming you have your heart set on doing this, I believe the general consensus is to either use the text of the image, or encode / decode the image (base64). There are several threads you can look at, as I say, it has come up a lot. There are also lessons about images and databases. Here are a few of the links I've come across:
http://lessons.livecode.com/m/4071/l/26 ... a-database
https://forums.livecode.com/viewtopic.php?t=25064
https://forums.livecode.com/viewtopic.php?t=488
Image

dpalmersce@gmail.com
Posts: 25
Joined: Wed Aug 28, 2019 4:58 pm

Re: Images in databases

Post by dpalmersce@gmail.com » Mon Sep 30, 2019 1:48 pm

Thank you, everyone for all your help!

Post Reply

Return to “Converting to LiveCode”