Blob data
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
Blob data
Hi all,
Sorry to bother. I have a sqlite file with some data stored as blob.
I am not very familiar with this type of data and am currently reading up on it.
But is there any way for me to be able to display the data??
There is a column called thumb_image as well, which looks... well, odd.
I am wondering if they have anything to do with each other.
I have attached an image for you guys to view.
Any help will be appreciated!!
Thank you!
Gautami
Sorry to bother. I have a sqlite file with some data stored as blob.
I am not very familiar with this type of data and am currently reading up on it.
But is there any way for me to be able to display the data??
There is a column called thumb_image as well, which looks... well, odd.
I am wondering if they have anything to do with each other.
I have attached an image for you guys to view.
Any help will be appreciated!!
Thank you!
Gautami
- Attachments
-
- Untitled1.png (22.74 KiB) Viewed 10924 times
Re: Blob data
From what I see, BLOB is just a string, though sometimes quite long, and may contain any sort of data. The SQL server does not interpret this string.
So there should be no issue with displaying such data, apart from possible length issues. But if the string contains characters that you might want to use as itemdelimiters, such as tab or comma, this might make the display unmanageable.
What does the raw_data in line 1 of your example look like? It seems like tabs and returns worked in that example.
Craig Newman
So there should be no issue with displaying such data, apart from possible length issues. But if the string contains characters that you might want to use as itemdelimiters, such as tab or comma, this might make the display unmanageable.
What does the raw_data in line 1 of your example look like? It seems like tabs and returns worked in that example.
Craig Newman
Re: Blob data
Hi,
Thanks for the reply.
So the {BLOB} itself contains some long string of data that I can't view in the sql browser.. I see.
*enlightened*
Well, the raw_data of line 1 looks as in the picture.
Is there some kind of decoding I have to do for blob data?
Gautami
Thanks for the reply.
So the {BLOB} itself contains some long string of data that I can't view in the sql browser.. I see.
*enlightened*
Well, the raw_data of line 1 looks as in the picture.
Is there some kind of decoding I have to do for blob data?
Gautami
- Attachments
-
- Untitled.png (6.92 KiB) Viewed 10902 times
Re: Blob data
the problem is: how do you store the data of the image?
the imageData of an image is the data (binary) of an image that you should store and recover from a BLOB value of a database.
When you create the database the column containing data must be BLOB type, otherwise data will be converted and corrupted.
the imageData of an image is the data (binary) of an image that you should store and recover from a BLOB value of a database.
When you create the database the column containing data must be BLOB type, otherwise data will be converted and corrupted.
Livecode Wiki: http://livecode.wikia.com
My blog: https://livecode-blogger.blogspot.com
To post code use this: http://tinyurl.com/ogp6d5w
My blog: https://livecode-blogger.blogspot.com
To post code use this: http://tinyurl.com/ogp6d5w
Re: Blob data
careful: imageData is not the complete binary representation of the image, it it just a binary representation of all the pixel.the imageData of an image is the data (binary) of an image that you should store and recover from a BLOB value of a database.
There is more to an image than imageData.
You could store
Code: Select all
the text of image "myImage"
if you just store the imageData you would have to provide an image object of exactly the same size and height as the original image and then set the imageData of that image object to your blob stuff.
Kind regards
Bernd
Re: Blob data
Hi,
thank you for the reply
However, I am still not getting it;
when i
put the text of image "myImage" to pix
put "myImage" into img "image01"
I am getting nothing.
i am not familiar with images stored in the sqlite files and am struggling with it. It has 3 columns of interest: media_url, thumb_image and raw_data. The first column is a expired url, the second has some characters in it and the third says {blob}....
When the sqlite db is run through a python script, the html file generated is somehow able to extract and display the image, which is through this :
"data:image/jpg;base64,\n" + base64.b64encode(y.media_thumb).decode("utf-8")
i have tried to replicate it in livecode by getting the image data, base64encode it and then decode it using utf-8. Still nothing......
Any suggestions will be welcome..
exhausted,
G
thank you for the reply

However, I am still not getting it;
when i
put the text of image "myImage" to pix
put "myImage" into img "image01"
I am getting nothing.
i am not familiar with images stored in the sqlite files and am struggling with it. It has 3 columns of interest: media_url, thumb_image and raw_data. The first column is a expired url, the second has some characters in it and the third says {blob}....
When the sqlite db is run through a python script, the html file generated is somehow able to extract and display the image, which is through this :
"data:image/jpg;base64,\n" + base64.b64encode(y.media_thumb).decode("utf-8")
i have tried to replicate it in livecode by getting the image data, base64encode it and then decode it using utf-8. Still nothing......
Any suggestions will be welcome..
exhausted,
G
Re: Blob data
Hi Gautami,
sorry I was not very explicit in my previous post, I mainly wanted to make you aware of the imageData as used in LIveCode and the binary representation of the whole image.
I made a small script that shows the syntax for getting images and setting images to binary data.
Make a new stack and 1 field. Drag drop an image from your hard disk to the field and the path will be in the field (you could also use answer file)
1 button with the following script:
What this shows: first you load the binary data from the file into a variable.
Basically that is what you could strore in your blob after base64encoding. No UTF-8, this is binary data. To unload you would have to base64decode the blob into a variable and set the text of an image to that variable.
The script shows variants of the syntax.
If you use text of image you have to codesince the text of an image is a PROPERTY, set works with properties.
you could say, as shown, in that case you treat image 2 as a CONTAINER, put works with containers.
Please have a look at the script, as far as I see it should get you going.
Kind regards
Bernd
sorry I was not very explicit in my previous post, I mainly wanted to make you aware of the imageData as used in LIveCode and the binary representation of the whole image.
I made a small script that shows the syntax for getting images and setting images to binary data.
Make a new stack and 1 field. Drag drop an image from your hard disk to the field and the path will be in the field (you could also use answer file)
1 button with the following script:
Code: Select all
on mouseUp
put field 1 into tImagePath
put url ("binfile:" & tImagePath) into tImage -- now tImagePath has the binary data of an image file, NOTE parenthesis ("binfile:" & variable)
if there is an image "myFirstImage" then
set the text of image "myFirstImage" to tImage
else
create image "myFirstImage"
set the text of image "myFirstImage" to tImage
end if
set the topLeft of image "myFirstImage" to 40,40 -- just so the images dont pile up in the center of the card
if there is an image "mySecondImage" then
set the text of image "mySecondImage" to the text of image 1
else
create image "mySecondImage"
set the text of image "mySecondImage" to the text of image 1
end if
set the topLeft of image "mySecondImage" to 80,80 -- just so the images dont pile up in the center of the card
if there is an image "myThirdImage" then
put image 1 into image "myThirdImage"
else
create image "myThirdImage"
put image 1 into image "myThirdImage"
end if
set the topLeft of image "myThirdImage" to 120,120 -- just so the images dont pile up in the center of the card
end mouseUp
Basically that is what you could strore in your blob after base64encoding. No UTF-8, this is binary data. To unload you would have to base64decode the blob into a variable and set the text of an image to that variable.
The script shows variants of the syntax.
If you use text of image you have to code
Code: Select all
set the text of image "myImage" to myVariable
you could say, as shown,
Code: Select all
put image 1 into image 2
Please have a look at the script, as far as I see it should get you going.
Kind regards
Bernd
Re: Blob data
HI Gautami,
in addition to my above post:
a variant that base64encodes and base64decodes the data.
Kind regards
Bernd
in addition to my above post:
a variant that base64encodes and base64decodes the data.
Code: Select all
on mouseUp
put field 1 into tImagePath
put url ("binfile:" & tImagePath) into tImage -- now tImagePath has the binary data of an image file, NOTE parenthesis ("binfile:" & variable)
put base64encode(tImage) into tImageBase64 -- this is probably what you want to store in your blob
-- get data out of your blob (not shown here)
-- and base64decode it:
put base64decode (tImageBase64) into tImageBinary
if there is an image "myFirstImage" then
set the text of image "myFirstImage" to tImageBinary
else
create image "myFirstImage"
set the text of image "myFirstImage" to tImageBinary
end if
end mouseUp
Bernd
Re: Blob data
Use http://sourceforge.net/projects/sqlitebrowser/ (it's free) to edit, check, create SQLite db. Verify that the third column is of BLOB type.
Livecode Wiki: http://livecode.wikia.com
My blog: https://livecode-blogger.blogspot.com
To post code use this: http://tinyurl.com/ogp6d5w
My blog: https://livecode-blogger.blogspot.com
To post code use this: http://tinyurl.com/ogp6d5w
Re: Blob data
Hi Max and Bernd,
thank you so much!
I am now able to understand blob data better!
Thanks!!
G
thank you so much!
I am now able to understand blob data better!

Thanks!!
G
Re: Blob data
Hi Gautami,
great you got it working, but you also should really understand why this:
...
put the text of image "myImage" to pix
put "myImage" into img "image01"
...
CANNOT work at all (to say the least)!
Best
Klaus
great you got it working, but you also should really understand why this:
...
put the text of image "myImage" to pix
put "myImage" into img "image01"
...
CANNOT work at all (to say the least)!

Best
Klaus
Re: Blob data
Hi Klaus,
LOL.
Ooops, haha
I got it.
This may be a better bet :
put the text of image "myImage" to pix
put pix into img "image01"
Gautami
LOL.
Ooops, haha
I got it.
This may be a better bet :
put the text of image "myImage" to pix
put pix into img "image01"
Gautami
Re: Blob data
Hi Gautami,

Best
Klaus
not at all, the first line will still throw an error!Gautami wrote:This may be a better bet :
...
put the text of image "myImage" to pix
put pix into img "image01"
...

Best
Klaus
Re: Blob data
Really??
oh no..
i will figure it out later and get back to ya
Gautami
oh no..
i will figure it out later and get back to ya

Gautami
Re: Blob data
OK, a little hint:
set whatever TO anothervalue
put whatever ? anothervalue
Replace the ? with the correct term
set whatever TO anothervalue
put whatever ? anothervalue
Replace the ? with the correct term
