SQLite Images and Standalone Issues

Creating desktop or client-server database solutions?

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Klaus
Posts: 13793
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: SQLite Images and Standalone Issues

Post by Klaus » Sun Aug 14, 2016 2:34 pm

Glad you could solve your problem, but what exactly was the problem in the end?

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

Re: SQLite Images and Standalone Issues

Post by bogs » Tue Feb 20, 2018 5:35 pm

I know, I know, 2 year old thread :mrgreen: I actually came across it looking for information about pictures in sqlite dbs. Klaus, you've been waiting a long time for this answer, though, and I love it when I can pitch in for you!
Klaus wrote:
Sun Aug 14, 2016 2:34 pm
Glad you could solve your problem, but what exactly was the problem in the end?
Ormente came up with the answer, which was (pertinent parts in bold underline) -
Ormente wrote:
Sat Aug 13, 2016 11:19 pm
...
I gave a look at it, and i suspected the problem came from a lack of "metadata" about the cropped image stored in the DB. Somehow, the standalone could not figure out what to do with the retrieved data : If i saved the main image in the cropped field of the DB, it came back perfectly, but not the cropped one. This one was missing something, and that was not due to the writing/retrieving process since the other one go thru the same.

So, i gave a look at the doc and found that the "export snapshot" (on the CropIt button) can have a format specified, like AS JPEG. Simply adding this solved the issue for me. Give it a try.

For some mysterious reason the interactive livecode is more forgiving and try harder to figure out what to do with the data... but specifying a format seems to ensure the correct image header is included in the binary data, so LC know what it is when it get it back (ie how to decode it to a picture).
Unfortunately for me, I have a tougher nut to crack, a picture that was encoded in a different programming environment that I can't get to decode :?
Image

Saman Sjr.
Posts: 49
Joined: Sat Nov 30, 2013 6:40 am

Re: SQLite Images and Standalone Issues

Post by Saman Sjr. » Sun Feb 25, 2018 3:48 pm

Try revOpenDatabase your SQLite with "binary" option:
revOpenDatabase("sqlite", "mydb.sqlite", "binary" )

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

Re: SQLite Images and Standalone Issues

Post by bogs » Sun Feb 25, 2018 5:12 pm

Thank you for the suggestion Saman, The information being returned isn't raw binary though :)

The problem with the pictures is a couple fold.
  1. The language I was using at the time I wrote this program in didn't have an easy way to translate pictures to text, so one of our fellow's came up with a brilliant (but complicated) way to do it. However, it worked so a lot of us used it without understanding the full implications of it, a mistake I have managed to avoid since :D
  2. It encoded to base 64, but it did a lot of manipulations, line by line and column by column of the picture, maybe even dot by dot, then did the encode. I really haven't finished going through the entire code yet, it was quite a bit.
  3. It also looks like he broke each channel (rgb) down separately, along with (in that language) the rgbsurface mask. Fun fun :)
The upshot is that it looks like base64 encoded binary (**see picture), but it is not decoding using Lc's facilities. More than likely if I can't reconstruct his decoder in Lc, I'll just program a picture stripper in that previous language, strip em all out, then program an insert utility in Lc and stick them all back in again.

I'd most likely have to do that anyway, even if I found a way to decode it in this language, since I sure wouldn't want to have to deal with this problem further down the line all over again 8)

** Picture showing the first several lines of the returned data of one picture -
Selection_004.png
The returned information is a LOT larger than Lc's returned information for the same picture base64 encoded, about 2.6 times larger. Lc pic encoded = 80kb, encoded picture being retrieved from the db = 207+kb.

Just in case someone wanted to see what I'm pulling I've attached this picture, pulled from the db and put into a text file.
Selection_005.png
Selection_005.png (47.12 KiB) Viewed 8339 times
picText.zip
(108.08 KiB) Downloaded 257 times
Image

jameshale
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 474
Joined: Thu Sep 04, 2008 6:23 am
Location: Melbourne Australia

Re: SQLite Images and Standalone Issues

Post by jameshale » Mon Feb 26, 2018 1:21 am

If the images are all video related thumbnails then perhaps it would be easier to pull them from the web rather than try to decipher another’s algorithm.

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

Re: SQLite Images and Standalone Issues

Post by bogs » Mon Feb 26, 2018 6:38 am

What fun is that :twisted:
Just kidding, although I do like the small challenges this problem presents.

Of course, the resolution isn't as easy as just sucking the images off the imdb or the like, as it isn't just movie thumbs in this program. There are also other household items involved, many so old they are difficult to locate. The program was conceived by my wife, to keep track of everything we own. The original version has been (and still is) chugging away for over 10 years now.

Even if I could find and tap into all of them online, I would eschew relying on it, I've seen too many things disappear from the world wide time waster. Heck, even in Lc, a lot of the older information is gone that was linked in the resources. Storing locally would be the only way I know to offset that kind of (potential) loss.
Image

jameshale
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 474
Joined: Thu Sep 04, 2008 6:23 am
Location: Melbourne Australia

Re: SQLite Images and Standalone Issues

Post by jameshale » Mon Feb 26, 2018 8:27 am

Re the movie thumbs etc - I meant to download new ones to repopulate your new dB.
But as you have stated there are other images of things that may not be on the web, then decoding that blasted bit of clever but obtuse encoding seems the way to go.

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

Re: SQLite Images and Standalone Issues

Post by bogs » Mon Feb 26, 2018 4:08 pm

Well, that or like I said earlier, using that same language and bit of code to auto extract/name/save all the images to a folder, and then switching back to Lc to do the same in reverse. It is just an interesting puzzle to me at the moment, if I become too bored with it, I'll resort to method 2 in a flash :mrgreen:
Image

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

Re: SQLite Images and Standalone Issues

Post by bogs » Wed Feb 28, 2018 10:50 pm

Now this is where it gets to "so close, but no cigar" heh. The pic on the right is the picture I'm trying to pull. The pic on the left is....erm.....disgustingly close, but no cigar.
Image
Image

SparkOut
Posts: 2834
Joined: Sun Sep 23, 2007 4:58 pm

Re: SQLite Images and Standalone Issues

Post by SparkOut » Thu Mar 01, 2018 8:02 am

Do you know the dimensions of the extracted picture? It looks like the data is probably ok but needs to be placed into an image that has its size correctly set BEFORE inserting the data.

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

Re: SQLite Images and Standalone Issues

Post by bogs » Thu Mar 01, 2018 1:59 pm

Actually I do, and I tried that, but , well, heh see for yourself.
Image
The data of the picture itself is certainly still ok, as when I use the program I made it reads it in and out ok.

In the previous language, no matter the size of the container, it always put the image into it clearly, which makes me think I'm still missing a ...key to the formula. I'll be going over my notes one more time on the previous work.
Image

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

Re: SQLite Images and Standalone Issues

Post by jacque » Thu Mar 01, 2018 8:17 pm

Sparkout is right, this is what happens if there is even a single pixel difference in the size of the target image. Create an empty image object with the correct dimensions, then import the image, and then scale it afterward if you want.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

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

Re: SQLite Images and Standalone Issues

Post by bogs » Thu Mar 01, 2018 9:35 pm

In the above screen shot, that was exactly what I did, the image container was 'empty', it was set to the dimension of the picture as it was put into the db. Now, I have no doubt that what Sparkout and you are saying is very true, but that makes me pretty sad, since a lot of the pictures are not of the same dimensions.
Image

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

Re: SQLite Images and Standalone Issues

Post by jacque » Thu Mar 01, 2018 9:51 pm

Can you use an image editor to save them in a more standard format? Then import those?
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

MaxV
Posts: 1579
Joined: Tue May 28, 2013 2:20 pm
Location: Italy
Contact:

Re: SQLite Images and Standalone Issues

Post by MaxV » Thu Mar 01, 2018 11:09 pm

Here the solution, I wrote it in 2015 and I forgot it: https://livecodeitalia.blogspot.it/2015 ... se_46.html
Livecode Wiki: http://livecode.wikia.com
My blog: https://livecode-blogger.blogspot.com
To post code use this: http://tinyurl.com/ogp6d5w

Post Reply

Return to “Databases”