1

I have following image source in RTF.

{\*\shppict{\pict\pngblip\pichgoal1020\picwgoal1200
89504e470d0a1a0a0000000d494844520000005000000044080200000099342577000000017352474200aece1ce90000000467414d410000b18f0bfc
6105000000097048597300000ec300000ec301c76fa8640000033449444154785eed9a4b8edc300c44fb12d96599c3e60a395aae102067e8105d6582
2e49b4d4767b6cc70f8581cc9f58fd19cc621ecfff8cdbf0d5b90d5f829f8f6f109f036b0dfbe8638a5b06860dcbc4838b4b076ec34bc84488b93370
cd5f5a09b7e1cff3f7fb0f1113bbb0b7e1aabd3d3d9fd5b0b5b818ea631bc39db72665a3ab7bf15097b193e14e3f9d35b1aca725b29f619e527acaa4
e60b0cbfb165425e59666fc30bbc63d8eec8c5ba8932929014575343c38d61c33d7e2c12c568c1afdf7faa62baa03a2a995f65c0706bfbfc4a74b918
6dbb35b1624eec8db4e22d7a0d27738752888843112a85d62dc9ed55de372c5b1e565c7762c0b00c3a976823372c3da7162d550d4b694b28cebf42e5
e7c2e3dee807a9846281d08a3b3207cc0cc78a522c9a93df5a6db716c81fed67ac8c6acd6fc51d99c3280c4b2e0a45c6d0c532c4c4c4546f3ffdf00a
eb4be3e7ea7ca31537bcd7c5c48b87e42026e754ef2883320a626eaab79f7e7885eb5da672be510d1ad20b3137a186196ee08b3af228d3cacd10c19c
98954617d38172a6215d10737368984f1dc87dc9d208c6023fdb01c2a321bd2ea603b10b488b89891a031f6920f7f9636b42acf7b31d20e92a857a27
4e33a4d8c4449bbae1a309bb46b75260626289231ab6b52462825b09422f23bdd4ffd292899f13ef2b90b2446ce826fbd3b2ca269f2b43be8d119f66
357e16b1749c370dcbf526643b49dc1a32b925560f326cd8285f7826bae9797b3bc5b66ede312c57e66f579521c3568c7a8947a1b787b5861119f29c
17c7e1c97c293331b1c42ac37c7ee1ef43026af2b238dc2bcb1644bcd8856cc2da775856b1c744490d522552e662fa45dc0762a2c6aedfe172572749
198b57c84a10737336306c6222657169237939784a91ad20e626de310c64eee24e3b1806b218c4dc1ac3860c85982bd8cd3090ad4c88af326cc85017
d3139d1b6f6818945bad35ecc86897eddaef7673c386ecb3996120d345b09488530a92540f71878d0d3bf18e9658dac14ac3865ffa29c38edfb42836
ccc9dff92170cbc70d1bbeb17beb516cdc0a1b3b6658fea7f4148a2f629761e93f9d6ec34b483fa3a7658f5f5a87e2367c756ec357e7367c756ec357
e7367c6d9ecf7fb9245ee11e01346e0000000049454e44ae426082
}}

question 1: what this 45bad35ecc86897eddaef7673c38 code is called (hexadecimal something)? question 2: How I save say png image from above source?

2
  • Could be some kind of base64 encoding or similar, for sending binary files through text-only routes. Where'd you get it, what is it?
    – Xen2050
    Apr 8, 2016 at 16:14
  • It is from RTF. If I enclose above code with {\rtf {image code} } will open with ms-word fine. Apr 9, 2016 at 1:51

1 Answer 1

0

It's actually a direct hex representation of the binary .png image, not even base64 encoded. In other words, if you create a file called mypng.png where the first byte is 0x89, the second one is 0x50, and so on, ignoring the newlines in the text, you should be able to open and view the picture. (In this case it's a scribble).

As to how to convert it, well, it depends.

Just to give you a starting point, since you have Word, if you open the file in Word as a text file (so you can see the RTF code rather than the picture - you may have to set the "confirm conversions at open" Word Option to do that), select the data bytes, and run the following code (you will need to change the file/path name), you should be able to open the output .png

Sub saveSelectionAsBinary()
Const pngpath As String = "c:\a\mypng.png"
Dim i As Long
Dim s As String * 1
Dim t As String
Kill pngpath
Open pngpath For Binary As 1
t = Selection.Text
i = 1
Do While i <= Len(t)
  If Mid(t, i, 1) = vbCr Then
    Debug.Print "cr"
    i = i + 1
  Else
    s = Chr(Val("&H" & Mid(t, i, 2)))
    Put #1, , s
    i = i + 2
  End If
Loop
Close #1
End Sub

I suppose it is obvious that "pngblip" tells us that this is supposed to be a .png format picture, but there can be other types of picture in an RTF pict, and they are not necessarily encoded this way.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .