Bill-Lancaster wrote: > I have a database containing thumbnail images in a type blob field (mysql). > Can someone help me to convert these to .png type files on disk? > Thanks > Bill, this may/may not work for you, I'm using postgres, It's probably crap code as I'm not much of a programmer, but this is what I use. If you were smart there is probably a one-liner - maybe whoever replies with a real solution I can update my code!
Public Function Image_get(pk_image As Integer, Optional bHas_MD5Sum As Boolean = False) As String '-------------------------------------------------------------------------------------------------------------------------------------------- 'Gets an image from the backend returns the filename 'pk_image = key to the blobs.images table 'all progress note/procedures images will have an md5sum, not so patient pictures '-------------------------------------------------------------------------------------------------------------------------------------------- Dim $Result As Result Dim tempFile As String Dim tempPicture As Variant Dim sql As String = "Select * from blobs.images WHERE pk=" & pk_image If bHas_MD5Sum Then sql &= " AND md5sum is not null" Endif $Result = modDBConnect.exec_query(sql) '** YOU WON'T USE THIS - USE YOUR OWN CODE If $Result.count Then tempFile = Temp() & ".png" tempPicture = $Result!image If tempPicture.data Then File.Save(tempFile, tempPicture.data) End If End If Return tempFile End REgards richard ------------------------------------------------------------------------------ Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ _______________________________________________ Gambas-user mailing list Gambas-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gambas-user