Page 1 of 1
					
				Decode in livecode
				Posted: Sat Aug 10, 2013 4:20 pm
				by Babyprincess
				I have images in my database. How do i extract them & view them on livecode itself ?I believe i need to decode the string, anyone knows whats the code to decode
			 
			
					
				Re: Decode in livecode
				Posted: Sat Aug 10, 2013 4:34 pm
				by Klaus
				Hi Babyprincess (Really? C'mon 

 )
1. welcome to the forum!
2. It depends on how the strings are ENCODED!
Any idea how? And are that really "strings"?
Best
Klaus
 
			 
			
					
				Re: Decode in livecode
				Posted: Sat Aug 10, 2013 5:24 pm
				by Babyprincess
				Thank you very much. I actually copied the "strings" into some online decoder (base64) & it did decode & output the image. All my image data are in my database, however i can't see the thumbnail view of them, that's why i believe i am supposed to decode it ): Please help me.
			 
			
					
				Re: Decode in livecode
				Posted: Sat Aug 10, 2013 5:36 pm
				by Klaus
				Ah, OK, that helps 
Do this to display the db output (I use the variable db_image_output in my example) into an image object (dbimage)
...
## fetch your "image string" from the database, put it into a variable, 
## decode that variable and simply "put" it into an existing image object:
put base64decode(db_image_output) into img "dbimage"
...
Best
Klaus
 
			 
			
					
				Re: Decode in livecode
				Posted: Mon Aug 12, 2013 9:27 am
				by Babyprincess
				Hi Klaus,
Thank you so much for your help (: 
I tried doing this, am i on the right track? But i got an error [(Chunk: no such object) near "dbimage", char 26] ): 
When i named my 'Image Area' as dbimage, i don't have any error but there is no output of any images
on mouseUp
   put media_name into columnName
   put "data" into CN2
   put base64decode(CN2) into img "dbimage"
   put "SELECT messages." & columnName & ",messages." & CN2 & " FROM messages WHERE messages." &columnName& "= messages." &columnName&"" into sql
   put databaseGetData(sql) into ptext
   set the dgText of group "Table" to ptext
  
end mouseUp
sincerly,
Babyprincess (:
			 
			
					
				Re: Decode in livecode
				Posted: Mon Aug 12, 2013 1:12 pm
				by Klaus
				Hi Babyprincess,
please check these stacks to get the basics of Livecode:
http://www.hyperactivesw.com/revscriptc ... ences.html
Babyprincess wrote:...
I tried doing this, am i on the right track? But i got an error [(Chunk: no such object) near "dbimage", char 26] ): 
When i named my 'Image Area' as dbimage, i don't have any error ...
Sigh, I did not think that it is neccessary to note that the object names in my EXAMPLE script may not fit YOUR actual object names! Is it? 
Babyprincess wrote:... but there is no output of any images
...
put "data" into CN2
put base64decode(CN2) into img "dbimage"
...
Do you really exspect that the TEXT "data" will turn into an IMAGE after you base64decode it?
Although it may seem to some people that programming is some kind of witchcraft, I can assure you that this is not the case! 
Of course you need to get the correct "image-string" form your database and then base64decode and use THAT string:
...
## HINT: This is an example and you may need to modify the herein used object names to fit your script!
put "SELECT your_image from your_table WHERE XXX = YYY" into tSQL
## I think "databaseGetData" is a custom function?
## whatever, I hope you get the picture!
put databaseGetData(tSql) into pImage
put base64decode(pImage) into img "Image Area"
...
Best
Klaus
 
			 
			
					
				Re: Decode in livecode [Complete Beginner]
				Posted: Mon Aug 12, 2013 6:36 pm
				by Babyprincess
				Hi Klaus,
I'm sorry but i'm quire confused. This is the first time i'm coding in livecode that's why.
I tried what you said but then i kept getting various errors & my original output did not appear, so i alter'd the code again to this,i got 2 outputs extracted. It just appeared on my dektop with the image name. But i was unable to view it. Haiz,it's still not working. I'm kinda noob in live-code. Please help me. Sorry ):
on mouseUp
   put media_name into columnName
   put "data" into CN2
   put media_wa_name into CN3
   put "SELECT messages." & columnName & ",messages." & CN2 & " FROM messages WHERE messages." &columnName& "= messages." &columnName&"" into sql
   put databaseGetData(sql) into ptext
   set the dgText of group "Table" to ptext
   put databaseGetData(sql) into pImage
   put base64decode(pImage) into  img "Image Area"
  
end mouseUp
A little background on what i'm doing- I'm doing a project on Whatsapp forensics. So i have to extract the images from the database & display in a thumbnail format. I've managed to actually been able to decrypt n display all the other informations. But i'm stuck at the images part.
			 
			
					
				Re: Decode in livecode
				Posted: Mon Aug 12, 2013 6:55 pm
				by Babyprincess
				This is how i display'd all the other information from my whatsapp decrypted database
on mouseUp
   ask "Table name"  #messages-for my reference i included this
   put it into table
   
   put databaseGetTableNames(table) into theFields
   replace "," with CR in theFields
   set the dgProp["columns"] of group "DataGrid 2" to theFields
   
   ask "SQL Statement" #SELECT*FROM messages-for my reference i included this
   put it into sql
   put databaseGetData(sql) into ptext
   set the dgText of group "DataGrid 2" to ptext
end mouseUp
When i run this, all my whatsapp conversation informations are displayed. But...
- For contents with images, the "thumbnail" column does not show the thumbnail of the image but it does have a weird sign there which i believe indicates the presence of a image under that column
			 
			
					
				Re: Decode in livecode
				Posted: Tue Aug 13, 2013 7:21 pm
				by Babyprincess
				Hi Klaus,
Thank you so much for your help and guides. I've finally managed to output my images. Thank you so much.
The error i kept having was my naming conventions. After i check'd my naming conventions thoroughly, i managed to see where i went wrong.
Thank you once again for your genuine help. 
Sincerely,
Babyprincess (ME) (:
			 
			
					
				Re: Decode in livecode
				Posted: Tue Aug 13, 2013 9:28 pm
				by Klaus
				Hi Babyprincess,
glad you got it working!
"Haiz"? Are you from Singapur? 
Best
Klaus
 
			 
			
					
				Re: Decode in livecode
				Posted: Wed Aug 14, 2013 2:54 pm
				by Babyprincess
				Hahahas.. Yes !
			 
			
					
				Re: Decode in livecode
				Posted: Wed Aug 14, 2013 3:20 pm
				by Klaus
				
Your message contains 3 characters. The minimum number of characters you need to enter is 10.