<?xml version="1.0"?>
<!DOCTYPE rfc SYSTEM "rfc2629.dtd">
<?rfc toc="yes"?>

<!--
     ASCII to XML transformation by Invisible Worlds, Inc.
     http://invisible.net/
     Last transformation: 03-Feb-1999, 02:04:13

     Cannonical version of this document is at:
     http://info.internet.isi.edu/in-notes/rfc/files/rfc2159.txt

     Implementors should verify all content with
     cannonical version.  Failure to do so may result in
     protocol failures.
-->

<rfc number="2159"
     category="std">
<front>
<title abbrev="MIME Body Part for FAX">A MIME Body Part for FAX</title>
<author initials="H.T." surname="Alvestrand" fullname="Harald Tveit Alvestrand">
<organization>UNINETT</organization>
<address>
<postal>
<street>P.O.box 6883 Elgeseter</street>
<street>N-7002 Trondheim</street>
<country>NORWAY</country>
</postal>
<email>Harald.T.Alvestrand@uninett.no</email>
</address>
</author>
<date month="January" year="1998"/>
<area>Applications</area>
<keyword>ITU message handling service protocol</keyword>
<keyword>facsimile</keyword>
<keyword>multipurpose internet mail extensions</keyword>
</front>
<middle>
<!-- RFC original section: (1.) -->
<section title="Introduction">
<t>
   This document contains the definitions, originally contained in RFC
   1494, on how to carry CCITT G3Fax in MIME, and how to translate it to
   its X.400 representation.
</t>
<t>
   NOTE: At the moment, this format does not seem appropriate for a
   &quot;general purpose image format for the Internet&quot;, if such a beast can
   exist. It exists only to carry information that is already in G3 Fax
   format, and may be usefully converted to other formats when used in
   specific contexts.
</t>
</section>
<!-- RFC original section: (2.) -->
<section title="The image/g3fax content-type">
<t>
   This content-type is defined to carry G3 Facsimile byte streams.
</t>
<t>
   In general, a G3Fax image contains 3 pieces of information:
<list>
<t>
     (1)   A set of flags indicating the particular coding scheme.
           CCITT Recommendation T.30 defines how the flags are
           transmitted over telephones.  In this medium, the flags are
           carried as parameters in the MIME content-type header
           field.
</t>
<t>
     (2)   A structure that divides the bits into pages.  CCITT
           recommendation T.4 describes a &quot;return to command mode&quot;
           string; this is used here to indicate page breaks.
     (3)   For each page, a sequence of bits that form the encoding of
           the image.  CCITT recommendation T.4 defines the bit image
           format.  This is used without change.  The highest bit of
           the first byte is the first bit of the T.4 bitstream.
</t></list>
</t>
<!-- RFC original section: (2.1.) -->
<section title="G3Fax Parameters">
<t>
   The following parameters are defined:
<list>
<t>
      (1)   page-length - possible values: A4, B4 and Unlimited
</t>
<t>
      (2)   page-width - possible values: A3, A4, B4
</t>
<t>
      (3)   encoding - possible values: 1-dimensional, 2-dimensional,
            Uncompressed
</t>
<t>
      (4)   resolution - possible values: Fine, Coarse
</t>
<t>
      (5)   DCS - a bit string, represented in Base64.
</t>
<t>
      (6)   pages - an integer, giving the number of pages in the
            document
</t></list>
</t>
<t>
   If nothing is specified, the default parameter settings are:
</t>
<figure><artwork>
      page-length=A4
      page-width=A4
      encoding=1-dimensional
      resolution=Coarse
</artwork></figure>
<t>
   It is possible (but misleading) to view the representation of these
   values as single-bit flags. They correspond to the following bits of
   the T.30 control string and X.400 G3FacsimileParameters:
</t>
<figure><artwork>
       Parameter               T.30 bit        X.400 bit

       page-length=A4             no bit set
       page-length=B4          19              21
       page-length=Unlimited   20              20

       page-width=A4              no bit set
       page-width=A3           18              22
       page-width=B4           17              23

       encoding=1-dimensional     no bit set
       encoding=2-dimensional  16              8
       encoding=Uncompressed   26              30

       resolution=Coarse          no bit set
       resolution=Fine         15              9
</artwork></figure>
<t>
   The reason for the different bit numbers is that X.400 counts bits in
   an octet from the MSB down to the LSB, while T.30 uses the opposite
   numbering scheme.
</t>
<t>
   If any bit but these are set in the Device Control String, the DCS
   parameter should be supplied.
</t>
</section>
<!-- RFC original section: (2.2.) -->
<section title="Content Encoding">
<t>
   X.400 defines the g3-facsimile data stream as a SEQUENCE of BIT
   STRINGs. Each BIT STRING is a page of facsimile image data, encoded
   as defined by Recommendation T.4.  The following content encoding is
   reversible between MIME and X.400 and ensures that page breaks are
   honored in the MIME representation.
</t>
<t>
   An EOL is defined as a bit sequence of
</t>
<figure><artwork>
       000000000001 (eleven zeroes and a one).
</artwork></figure>
<t>
   Each page of the message is delimited by a sequence of six (6) EOLs
   that MUST start on a byte boundary.  The image bit stream is padded
   with zeroes as needed to achieve this alignment.
</t>
<t>
   Searching for the boundary is a matter of searching for the byte
   sequence (HEX) 00 10 01 00 10 01 00 10 01, which cannot occur inside
   the image.
   See Section 7.5 for the algorithm on conversion between this encoding
   and the X.400 encoding.
</t>
<t>
   The Base64 content-transfer-encoding is appropriate for carrying this
   content-type.
</t>
</section>
</section>
<!-- RFC original section: (3.) -->
<section title="g3-facsimile - image/g3fax">
<t>
   X.400 Body part: g3-facsimile
   MIME Content-Type: image/g3fax
   Conversion Type: nearly Byte copy
   Comments:
</t>
<t>
   The Parameters of the X.400 G3Fax body part are mapped to the
   corresponding Parameters on the MIME Image/G3Fax body part and vice
   versa.  Note that:
<list>
<t>
      (1)   If fineResolution is not specified, pixels will be twice as
            tall as they are wide
</t>
<t>
      (2)   If any bit not corresponding to a specially named option is
            set in the G3Fax NonBasicParameters, the &quot;DCS&quot; parameter
            must be used.
</t>
<t>
      (3)   Interworking is not guaranteed if any bit apart from those
            specially named are used in the NonBasicParameters
</t></list>
</t>
<t>
   From X.400 to G3Fax, the body is created in the following way:
<list>
<t>
      (1)   Any trailing EOL markers on each bitstring is removed. The
            bit order is changed to conform to the most common Internet
            encoding (highest bit of first byte = first bit of the
            G3Fax). The bitstring is padded to a byte boundary.
</t>
<t>
      (2)   6 consecutive EOL markers are appended to each bitstring.
</t>
<t>
      (3)   The padded bitstrings are concatenated together
</t></list>
</t>
<t>
   An EOL marker is the bit sequence 000000000001 (11 zeroes and a
   one).
</t>
<t>
   From G3Fax to X.400, the body is created in the following way:
<list>
<t>
      (1)   The body is split into bitstrings at each occurrence of 6
            consecutive EOL markers. Trailing EOLs must NOT be removed,
            since the X.400 Implementor Guide recommends that each page
            should end with 6 consecutive EOLs.  (This is a change from
            RFC 1494).
      (2)   Each bitstring is made into an ASN.1 BITSTRING, reversing
            the order of bits within each byte to conforom to the X.400
            Implementors Guide recommendation for bit order in the
            G3Fax body part.
</t>
<t>
      (3)   The bitstrings are made into an ASN.1 SEQUENCE, which forms
            the body of the G3Fax body part.
</t></list>
</t>
</section>
<!-- RFC original section: (4.) -->
<section title="Usability of G3Fax body parts">
<t>
   This section is not part of the proposed standard, but is intended as
   guidance for people implementing G3Fax handling, so that they know a
   little about what to expect.
</t>
<t>
   The DCS bitstring is a LONG thing; the T.30 Recommendation (1993)
   gives 67 bits with specific functions, SG8 Report R33 extends this to
   75 bits, and Report R41 (approved in 1995) extends it to 79 bits.
   (For curiosity - bit 68 says that the coding is JPEG; bit 27 is
   &quot;error correcting mode). No sane implementor will send such things
   without being able to negotiate them down if the recipient doesn&apos;t
   support it, but there is no guarantee that messages with such bits
   set in the DCS won&apos;t arrive through X.400.
</t>
<t>
   The ISO P2 profile from 1995 [PROFILE] says that the profile makes
   support for reception of two-dimensional and fine-resolution
   mandatory if g3-facsimile is supported at all. Research by Andrew
   Gordon of Net-Tel indicates that it is easy for an access unit to
   support fine resolution, unlimited length and B4 length, while
   support for B4 width is nearly impossible, and A3 width is hard.
</t>
<t>
   Another interesting point is that some fax machines have trouble if
   the scan lines do not contain exactly the declared number of pixels
   on each scan line, so &quot;omitting right-hand white space&quot; is likely to
   give trouble.
</t>
</section>
<!-- RFC original section: (5.) -->
<section title="Security Considerations">
<t>
   There are no known security issues specific to the FAX body part.
</t>
</section>
<!-- RFC original section: (6.) -->
<section title="References (BOILERPLATE)">
<t>
This RFC contained boilerplate in this section which has been moved
to the RFC2223-compliant unnumbered section &quot;References.&quot;
</t>
</section>
<!-- RFC original section: (7.) -->
<section title="Author&apos;s Address (BOILERPLATE)">
<t>
This RFC contained boilerplate in this section which has been moved
to the RFC2223-compliant unnumbered section &quot;Author&apos;s Address.&quot;
</t>
</section>
<!-- RFC original section: (8.) -->
<section title="Full Copyright Statement (BOILERPLATE)">
<t>
This RFC contained boilerplate in this section which has been moved
to the RFC2223-compliant unnumbered section &quot;Full Copyright Statement.&quot;
</t>
</section>
</middle>
<back>
</back>
</rfc>
