compressionbinary-imagejbig2

To encode image using jbig2enc


I am trying to encode image using JBIG2 encoder that I have installed using Macports. https://ports.macports.org/port/jbig2enc/

I have also installed leptonica from Macports:
https://ports.macports.org/port/leptonica/

The system seems to have installed it:

% jbig2 -V --version                                                         
jbig2enc 0.28

Also, from jbig2 --help I am getting this

% jbig2 --help                                                                
Usage: jbig2 [options] <input filenames...>                                      
Options:                                                                       
  -b <basename>: output file root name when using symbol coding
  -d --duplicate-line-removal: use TPGD in generic region coder
  -p --pdf: produce PDF ready data
  -s --symbol-mode: use text region, not generic coder
  -t <threshold>: set classification threshold for symbol coder (def: 0.85)
  -T <bw threshold>: set 1 bpp threshold (def: 188)
  -r --refine: use refinement (requires -s: lossless)
  -O <outfile>: dump thresholded image as PNG
  -2: upsample 2x before thresholding
  -4: upsample 4x before thresholding
  -S: remove images from mixed input and save separately
  -j --jpeg-output: write images from mixed input as JPEG
  -a --auto-thresh: use automatic thresholding in symbol encoder
  --no-hash: disables use of hash function for automatic thresholding
  -V --version: version info
  -v: be verbose

As the encoder refers to https://github.com/agl/jbig2enc for encoding the images I tried the command they have mentioned for encoding:

$ jbig2 -s feyn.tif &gt;feyn.jb2

I ran it for an image original.jpg, This is what I am getting:

> jbig2 -s original.jpg &gt;original.jb2
[1] 43894
zsh: command not found: gt
zsh: command not found: original.jb2
sahilsharma@Sahils-Air ~ % JBIG2 compression complete. pages:1 symbols:5 log2:3
?JB2

?|?n6?Q?6?(m?զu? Y???_?&??1???<?CJ?????#Rᮛ?O?V??:?,??i4?A?????5?;ސA??-!????5Ѧ??/=n܄?*?#|J6@?J?6?N1?n??v?"E}?.~?+????ڜ?]HO_b??~?[??????S2p𩗩????fC?????X?Z?????X=?m?????
                                                                                                                                                                       ??jN?????i????S?,j6???Br?V??F???8?w?#?6? uK?V??R?s~F-?F%?j????]j???0?!GG"'?!??)2v??K???h-???1
[1]  + done       jbig2 -s original.jpg

According to '--help', '-s' will do the lossless encoding.
The execution shows JBIG2 compression completed but no jb2 files have been formed. Please help me in getting to know if the compression has taken place? Then where can I get the encoded image? I am running this encoder to get to know the compression ratio. So I just want to know the encoded image size.


Solution

  • Use >, not &gt;. The result will then be in feyn.jb2.