Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Converting JPEG in text format from email message source back into JPEG

I received an email a while ago with an image attachment in it. Since then, it seems hotmail has stopped hosting the image for me as when I open the message, the image is no longer available.

However, the message source is still intact, and if I'm not wrong, the message source - in text form - also contains the image.

The problem is of course it is in text form. The part which (I believe) contains the image looks something like this: (Just the first few lines)

--Apple-Mail-2--733971985

Content-Disposition: inline; filename=photo.JPG Content-Id: <3F8BDC26-81F3-4BA2-9071-53E78CB3DB63/photo.JPG>

Content-Type: image/jpeg; name=photo.JPG Content-Transfer-Encoding: base64

/9j/4AAQSkZJRgABAQEASABIAAD/4gxYSUNDX1BST0ZJTEUAAQEAAAxITGlubwIQAABtbnRyUkdC IFhZWiAHzgACAAkABgAxAABhY3NwTVNGVAAAAABJRUMgc1JHQgAAAAAAAAAAAAAAAAAA9tYAAQAA AADTLUhQICAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABFj cHJ0AAABUAAAADNkZXNjAAABhAAAAGx3dHB0AAAB8AAAABRia3B0AAACBAAAABRyWFlaAAACGAAA ABRnWFlaAAACLAAAABRiWFlaAAACQAAAABRkbW5kAAACVAAAAHBkbWRkAAACxAAAAIh2dWVkAAAD TAAAAIZ2aWV3AAAD1AAAACRsdW1pAAAD+AAAABRtZWFzAAAEDAAAACR0ZWNoAAAEMAAAAAxyVFJD

It was sent from my iPhone into Hotmail.

Is this text representing the image that I am missing? I don't believe there is a program out there that can convert this for me, so I am willing to write my own program to do it. Question is, is this even possible?

like image 822
Arvin Avatar asked Nov 08 '11 09:11

Arvin


People also ask

How do I change a file type to JPEG?

Go to File > Save as and open the Save as type drop-down menu. You can then select JPEG and PNG, as well as TIFF, GIF, HEIC, and multiple bitmap formats. Save the file to your computer and it will convert.

How do I download a picture from email?

Open the e-mail message containing the attachment. Right-click the picture or file and choose Save As or Save Image. Specify the location you want to save the file. You may also change the file name at this point.


1 Answers

Yes, this is entirely possible, by various methods. If you have the entire message source, you could save it into a file (something like *.eml) and open it in a mail client (e.g. Mozilla Thunderbird); this should show you the entire message including the attached image.

If not, it's still possible: as you can see from the headers, the image is base64-encoded. You need to revert this transformation - either using your own code (e.g. PHP has base64_decode()), or through various base64-decoders available online (e.g. this). The part you want to decode is the block starting with /9j/4AAQSk in this case. Rename the resulting file photo.JPG (as indicated in the e-mail headers) and you're done.

Note that this requires you to verify that you have put the entire base64-encoded file through the decoder - base64 has no marker to detect the end of file.

like image 175
Piskvor left the building Avatar answered Sep 22 '22 14:09

Piskvor left the building