Home Conversion of Image type to Text

# Conversion of Image type to Text

user46137
1#
user46137 Published in September 19, 2018, 6:43 pm

I'm having some trouble converting the below Image data type to text;

0x1F8B0800FC7E1F3000FF758FCB6EC2301045F748FCC3FC00D524518A0AAB967655D10D5D7AE324E360C9B1A3B179B4887FAF431254FAD8F83173E6DE3B27C14125425AAF2F47D9D6499AA742B16B021D03888A94C29350CE865098E9243E51287FD0DEC3236B6996E74B3111AA7115B18595DBB12686373A0CBDA867B511AADC4AF61452D87C34851B27B371F20AE0ADC6052B9D711C1308A60A45CD441645617684CB5FA534CF3B6DB12B13D14AAE446BA4B6DD2A4116D93D42BF438AF0BE2558EB929D772AC0CB3106B035C186781FDDD7529BC21DE36D651DFF5BE9A1744D6B2850052DBB92BCD7B686A607C97776D3C92648EE081916223A428A389FE1C30C73C07C91CD17E9BC075757B17FD12CEFD1F56831FA52354C0CFD588A213D346E3FB67088A33F099CEA3BD00CE080DC21C2EB530F3E531FE60772AB52FD0D7DD7397F01A585816657020000

I have tried casting as varbinary and then casting that to nvarchar, but get what looks like Unicode characters;

select top 1 cast(cast(body as varbinary(max)) as nvarchar(max)) from dbo.messagedata


How can I convert the above Image data into readable text?

• What do you mean by readable text? The point is that the data is binary and not readable by a human. What text would you expect an image to take? I suspect that isn't really what you want. What are you trying to accomplish? BTW, the image datatype has been deprecated in favor of varbinary(max) for over a decade now. – Sean Lange Nov 13 '17 at 15:01
• There is readable text, encoded behind that binary data. I know that for a fact. The database I am dealing is well over a decade old. I know Image type is depreciated, but I didn't make the database. – Sam Nov 13 '17 at 15:05
• Really??? Readable to turn it into an image perhaps but it is not going to just start reading like text. What you are seeing is a text representation of the binary data. The data you posted is exactly what I would expect for the text representation of a binary. Are you trying to display this as an image in some application? – Sean Lange Nov 13 '17 at 15:08
• Managed to sort it myself anyway. Turns out the data is GZip compressed. I decompressed the bytes in C# and managed to get the text back. – Sam Nov 13 '17 at 15:09
StackExchange.ready(function(){\$.get('/posts/47267252/ivc/f131');}); StackExchange.ready(function () { StackExchange.responsiveness.addSwitcher(); }) (function(i, s, o, g, r, a, m) { i['GoogleAnalyticsObject'] = r; i[r] = i[r] || function() { (i[r].q = i[r].q || []).push(arguments) }, i[r].l = 1 * new Date(); a = s.createElement(o), m = s.getElementsByTagName(o)[0]; a.async = 1; a.src = g; m.parentNode.insertBefore(a, m); })(window, document, 'script', 'https://www.google-analytics.com/analytics.js', 'ga'); StackExchange.ready(function () { StackExchange.ga.init({ sendTitles: true, tracker: window.ga, trackingCodes: [ 'UA-108242619-1' ] }); StackExchange.ga.setDimension('dimension2', '|sql|sql-server|tsql|'); StackExchange.ga.setDimension('dimension3', 'Questions/Show'); StackExchange.ga.trackPageView(); }); /**/ var _qevents = _qevents || [], _comscore = _comscore || []; (function() { var ssl = 'https:' == document.location.protocol, s = document.getElementsByTagName('script')[0], qc = document.createElement('script'); qc.async = true; qc.src = (ssl ? 'https://secure' : 'http://edge') + '.quantserve.com/quant.js'; s.parentNode.insertBefore(qc, s); _qevents.push({ qacct: "p-c1rF4kxgLUzNc" }); /**/ var sc = document.createElement('script'); sc.async = true; sc.src = (ssl ? 'https://sb' : 'http://b') + '.scorecardresearch.com/beacon.js'; s.parentNode.insertBefore(sc, s); _comscore.push({ c1: "2", c2: "17440561" }); })();
 You need to login account before you can post.
Processed in 0.482363 second(s) , Gzip On .