There are 2 types how a picture can be transmitted over an email, as inline picture, or as an attachement. Before they are transfer over, they need to go through some conversion, that is binary-to-text encoding called Base64.
Say, the binaries of the image starts with FF D8 FF, and the translation process can be as below :
Original binaries | FF D8 FF | |||
Regroup the binaries | 111111 | 111101 | 100011 | 111111 |
Associate decimal | 62 | 61 | 35 | 63 |
From the Base64 index table | / | 9 | j | / |
Inline image
To send as an inline, the email message shall have the following attributes.
Content-Type: image/gif; name="file name"
Content-Transfer-Encoding: base64
X-Attachment-Id: image-id
Content-ID: <image-id>
Followed by the image binaries in Base64. The attributes and the image binaries is placed within the content type boundary.
In the email content, to refer to the image, the source of image will be refered as
<img src="cid:image-id">
Attachment image
For image as an attachment (for download), the email message attributes will be different from the inline image.
Content-Type: image/gif; name="file name"
Content-Disposition: attachment; filename="file name"
Content-Transfer-Encoding: base64
X-Attachment-Id: image-id
Similar to inline image, the message is followed by the image binaries in Base64 format, and is enclosed within the content type boundary.
The highlighted are basically the attributes that differentiate the inline image and attachment image.
No comments:
Post a Comment