Bug 693594

Summary: Need JPEG and JBIG Compression support for fax class 2.1
Product: Ghostscript Reporter: Avadhut <avadhut.bhangui>
Component: Other DriverAssignee: Miles Jones <miles.jones>
Status: NOTIFIED WONTFIX    
Severity: enhancement CC: chris.liddell
Priority: P4    
Version: 9.05   
Hardware: PC   
OS: Linux   
Customer: 130 Word Size: ---

Description Avadhut 2013-01-28 11:07:48 UTC
Our requirement is to compress the outgoing fax with JPEG compression for color and JBIG compression for black and white. Does GS support compression for color JPEG document? As per documentation provided at following link  http://ghostscript.com/doc/current/Devices.htm#TIFF

We understand that there is no compression drivers for color documents in GS, however there are compression drivers for balck and white documents. The following are compression modes for balck and white documents. 

tiffcrle 
tiffg3 
tiffg32d 
tiffg4 
tifflzw 
tiffpack 

I have tried above devices in my lab and noticed that device "tiffg4" results in lower file size after transformation. Similarly we need a GS device for color JPEG whcih compress the file, so that files can be transferred quicly to the fax destinations. 

Please let me know if you need any other information.
Comment 1 Chris Liddell (chrisl) 2013-01-28 12:02:14 UTC
We don't support JPEG compression in TIFF files - use the JPEG deviced (jpeg jpegcmyk and jpeggray).

We don't support JBIG2 output in TIFF for two reasons: 1) because of the patent encumbered nature of JBIG2 encoding (which don't apply to decoding), and 2) because it would have few benefits over CCITT Group 4 FAX encoding.

Because Ghostscript "printer" devices (like the TIFF devices) generally deal with purely raster data, they don't have access to the "document level" analysis that would give the ability to identify, for example, areas of the image that can be optimised into JBIG2 text regions, pattern dictionaries and pre-halftoned regions. Since the "core" compression algorithm of JBIG2 is almost identical to G4, the result would be, at best, a similar compression level to G4, and at worst, a larger output file due to the extra complexity of the JBIG2 file and data stream structure.

In short, use the JPEG devices for JPEG, and use tiffg4 for monochrome.

Alternatively, if you *really* need compressed color TIFF output, you can use tiff32nc or tiff24nc, and use the "-sCompression=lzw" or "-sCompression=pack" command line options.
Comment 2 Avadhut 2013-01-29 06:19:06 UTC
Hi,

We have tried using with "-sCompression=lzw" or "-compression=pack" options with tiff32nc and  tiff24nc GS devices and notices the output file size is compressed to great extent. However when I use the with "-sCompression=lzw" or "-compression=pack" options with GS device “jpeg” there is no change in output file sizes. So this confirms that there is no compression technique in GS for JPEG and JBIG formats. 
Thanks for your earlier response. 

Regards,
Sumanth
Comment 3 Chris Liddell (chrisl) 2013-01-29 06:50:08 UTC
(In reply to comment #2)
> Hi,
> 
> We have tried using with "-sCompression=lzw" or "-compression=pack" options
> with tiff32nc and  tiff24nc GS devices and notices the output file size is
> compressed to great extent. However when I use the with "-sCompression=lzw"
> or "-compression=pack" options with GS device “jpeg” there is no change in
> output file sizes. So this confirms that there is no compression technique
> in GS for JPEG and JBIG formats. 

JPEG is already an aggressively (lossy) compressed image format, see:
http://en.wikipedia.org/wiki/JPEG

Since the JPEG format defines the compression scheme to be used in JPEG files, *additional* compression options are not required nor available.


It highly unlikely that applying LZW or packbits compression to an already heavily compressed format like JPEG will have any benefit - in fact, given that it will have (almost) all the redundant data compressed already, it is likely that the file would actually end up larger.