Looking at the MBtiles spec, the tile_data field of the tiles table is just a blob of a tile image.
With this information, I expected to be able to take a data URI, string it of everything except the base64 encoded string, and decode it for storage in the tile_data field.
For instance:
var dataURI = "data:image/jpeg;base64,[some_encoded_data]";
var unencodedBytes;
if (dataURI.split(',')[0].indexOf('base64') >= 0) {
unencodedBytes = atob(image.split(',')[1]);
} else {
unencodedBytes = unescape(dataURI.split(',')[1]);
}
At this point, my unencodedBytes variable should have raw jpeg image data, and as such, I should be able to insert it into a tile_data field, correct? Is there an additional step I need to take? The data looks like belongs there, based off my observations of other valid mbtiles files, however all the mbtiles viewers I try to view this either do not show the data, or say they cannot figure out what type of data it is (jpeg or png).
What am I doing wrong? This is all being run in javascript in a browser, and I am using WebSQL to create the mbtiles file, since it is (supposedly) compatible.
Thanks in advance