B4J Question Json BLOB to Image File Cluelessness

mmieher

Active Member
Licensed User
Longtime User
I am trying to recover thousands of personally valuable very old images that are stored in this mummified software titled PhotoRecall DELUXE, which stored the bmp(?) images in an Access 97 .mdb file. I cannot find the original software.

As usual, I do not know the correct keyword to search for.

I have gotten to a Json dump of the mdb relic with a tool I found. Here is the first abbreviated record:
B4X:
{"$binary": "/9j/4AAQSkZJRgABAAEAlgCWAAD//gAfTEVBRCBUZ   THIS GOES ON AND ON  87414 BYTES    lSRdynOGA==", "$type": "00"}

I have been trying things shown below. All this byte, bit, char, array stuff continues to confound me. I usually rely on a code-snippet from one of you to accomplish whatever.

B4X:
    Dim DIR As String = File.DirData("PhotoExport")
    Dim fn As String = "b4jtest.bmp"
   
    Dim parser As JSONParser
    parser.Initialize(Json)
    
    Dim jRoot As Map = parser.NextObject
    Dim jType As String = jRoot.Get("$type")
    Log("jType = " & jType)
    
    ''Dim binary As Object = jRoot.Get("$binary")
    Dim strBinary As String = jRoot.Get("$binary")
   
    Dim bc As ByteConverter
    'bc.LittleEndian = True
    Dim Buffer() As Byte = bc.StringToBytes(strBinary, "UTF8" )   ' <--- this cannot be right
    
    
'    Dim out As OutputStream = File.OpenOutput(DIR,fn,False)
'    out.InitializeToBytesArray(0)
'    Log("Buffer.Length = " & Buffer.Length)
'    out.WriteBytes( Buffer , 0, Buffer.Length)
'    'out.Flush
'    out.Close

    File.WriteBytes(DIR,fn, Buffer)
    
    Log("*** wrote bytes")

I end up with a ".bmp" file with a byte size that is darn close to correct, but definitely does not qualify on any planet as an "image".

I want to end up with a usable anything. These photos were taken with what might have been the first "modern" Sony camera thing. You needed to insert a 3.5" diskette, which would hold about six pictures at "extreme high quality". But they are the entire photographic record of my life before thirty, and The Rents life before me.
 
Solution
You could just go into the Chrome dev tools and insert a tag anywhere like this to see if it shows something:

B4X:
<img src="data:image/jpeg;base64,/9j/4AAQSkZJRgABAAEAlgCWAAD//gAfTEVBRCBUZ........">

or

<img src="data:image/png;base64,/9j/4AAQSkZJRgABAAEAlgCWAAD//gAfTEVBRCBUZ........">

mmieher

Active Member
Licensed User
Longtime User
Thank you, @alwaysbusy and @drgottjr! Wow.

I am not sure where to go from here but will try before asking for more B4Help.

I am absolutely certain that everyone wants to know about this specific image.

?...

Pictured on our right -- the older man trying to distance himself from his family -- is my seventeen-year-senior half-brother Brad. I had met Brad maybe four times before I was eleven, when our deranged mother, Ruby Lucille Allnutt (dead) sent me from Albuquerque, New Mexico to Seattle, Washington for a "two week Christmas visit". When I arrived that day in 1975 at SeaTac International, Brad thought our mother was coming too. He also did not realize (nor did I) that I had flown to Seattle on a one-way ticket.

His train-wreck wife is the proud one in the middle. Air Force One (left) is my half-nephew Chris, who I became free daycare for when he was six-months old in 1975. The graduate is Chris's full-brother, Mathew. Mathew was born four years to the day after Chris. I broke away from skateboarding on our street to watch Chris whilst younger bro was birthed.

Not long after that, I manipulated my way into a number of generous -- but later regretful -- families that provided my food and shelter. This went on until I finally got to college.

I last saw Chris at his wedding in Beverly Hills twenty years ago. I last saw Matt in Monterey, California a few years later. That visit would have been his first wedding, but was cancelled at the last minute after everyone already had plane tickets. Douchebag. I did have a good time at Pebble Beach though.

I can hardly wait to see what else is in that file. During that time period, I randomly went to Jon Bon Jovi's 30-something private birthday party in Las Vegas. That was crazy, Man!

Pictured: Mommy Dearest
Mom_Marilyn.jpg
 
Upvote 0

mmieher

Active Member
Licensed User
Longtime User
Thank you, @alwaysbusy and @drgottjr! Wow.

I am not sure where to go from here but will try before asking for more B4Help.

I am absolutely certain that everyone wants to know about this specific image.

?...

Pictured on our right -- the older man trying to distance himself from his family -- is my seventeen-year-senior half-brother Brad. I had met Brad maybe four times before I was eleven, when our deranged mother, Ruby Lucille Allnutt (dead) sent me from Albuquerque, New Mexico to Seattle, Washington for a "two week Christmas visit". When I arrived that day in 1975 at SeaTac International, Brad thought our mother was coming too. He also did not realize (nor did I) that I had flown to Seattle on a one-way ticket.

His train-wreck wife is the proud one in the middle. Air Force One (left) is my half-nephew Chris, who I became free daycare for when he was six-months old in 1975. The graduate is Chris's full-brother, Mathew. Mathew was born four years to the day after Chris. I broke away from skateboarding on our street to watch Chris whilst younger bro was birthed.

Not long after that, I manipulated my way into a number of generous -- but later regretful -- families that provided my food and shelter. This went on until I finally got to college.

I last saw Chris at his wedding in Beverly Hills twenty years ago. I last saw Matt in Monterey, California a few years later. That visit would have been his first wedding, but was cancelled at the last minute after everyone already had plane tickets. Douchebag. I did have a good time at Pebble Beach though.

I can hardly wait to see what else is in that file. During that time period, I randomly went to Jon Bon Jovi's 30-something private birthday party in Las Vegas. That was crazy, Man!

Pictured: Mommy Dearest
View attachment 139042
Was I supposed to start a new thread for this?
 
Upvote 0

TILogistic

Expert
Licensed User
Longtime User
?
B4X
1675819317938.png


Save Image Jpeg or Png
1675819359320.png


ref:
 
Upvote 0

drgottjr

Expert
Licensed User
Longtime User
the file posted by op was a text file composed of lines of loosely related json strings.
the file was small and apparently only reflected a very small set of the images which are
stored somewhere.

the file was composed of 3 json strings, the first 2 of which represented chunks of a jpeg
image. the 3rd string represented a complete image, a smaller - thumbnail, if you will -
version of the image represented by the first 2 json strings.

in order to re-create the images, you need to piece the chunks together. the pieces,
fortunately, are numbered 0 to x number of pieces. when you get to x, you have all the
pieces of a given image.

the chunks - or pieces - are base64 strings. you decode the strings to bytes, add all the
bytes together and you have a bitmap.

attached is an example solution to reading and processing the file.
 

Attachments

  • mmieher.zip
    244.2 KB · Views: 135
Last edited:
Upvote 0
Top