Page 1 of 1

How to set encoding options for bpg delegate?

Posted: 2016-10-03T04:10:17-07:00
by Marsu42
Fortunately, recent IM seem to feature the bpg format (if the bpg binaries are found) which I'd like to use instead of png for internal viewing purposes. But apart from setting image.bpg as the output ...

... how to I tweak the encoder, i.e. funnel command line options from IM to the bpgenc.exe? There are plenty that are important:

Code: Select all

BPG Image Encoder version 0.9.6
usage: bpgenc [options] infile.[jpg|png]

Main options:
-q qp                set quantizer parameter (smaller gives better quality,
                     range: 0-51, default = 29)
-f cfmt              set the preferred chroma format (420, 422, 444,
                     default=420)
-c color_space       set the preferred color space (ycbcr, rgb, ycgco,
                     ycbcr_bt709, ycbcr_bt2020, default=ycbcr)
-b bit_depth         set the bit depth (8 to 12, default = 8)
-lossless            enable lossless mode
-e encoder           select the HEVC encoder (x265, default = x265)
-m level             select the compression level (1=fast, 9=slow, default = 8)

Advanced options:
-alphaq              set quantizer parameter for the alpha channel (default = same as -q value)
-premul              store the color with premultiplied alpha
-limitedrange        encode the color data with the limited range of video
-hash                include MD5 hash in HEVC bitstream
-keepmetadata        keep the metadata (from JPEG: EXIF, ICC profile, XMP, from PNG: ICC profile)

Code: Select all

2) BPG encoder
--------------

The BPG command line encoder is 'bpgenc'. It takes JPEG or PNG images
as input.

- Speed: by default bpgenc uses the x265. You can compile the much
  slower but more efficient JCTVC encoder and select it with the '-e
  jctvc' option. With x265 you can select the encoding speed with the
  '-m' option (1 = fast, but larger image, 9 = slower but smaller
  image).

- Bit depth: the default bit depth is 8. You can increase it to 10
  ('-b 10' option) to slightly increase the compression ratio. For web
  publishing it is generally not a good idea because the Javascript
  decoder uses more memory. The compiled x265 encoder supports the bit
  depth of 8, 10 and 12. The slower JCTVC encoder can be compiled to
  support higher bit depths (up to 14) by enabling the Makefile
  define: USE_JCTVC_HIGH_BIT_DEPTH.

- Lossless compression is supported as a bonus thru the HEVC lossless
  capabilities. Use a PNG input in this case unless you know what you
  do ! In case of a JPEG input, the compression is lossless related to
  the JPEG YCbCr data, not the RGB data. In any case, the bit depth
  should match the one of your picture otherwise the file size
  increases a lot. By default the lossless mode sets the bit depth to
  8 bits. The prefered color space is set to "rgb". Notes: 
  
    - lossless mode is less tested that the lossy mode but it usually
      gives better results that PNG on photographic images.

    - the JCTVC encoder gives smaller images than the x265 encoder
      with lossless compression.

- There is a small difference of interpretation of the quantizer
  parameter (-q option) between the x265 and JCTVC encoder.

- Color space and chroma format:

    * For JPEG input, the color space of the input image is not
      modified (it is YCbCr, RGB, YCbCrK or CMYK). The chroma is
      subsampled according to the preferred chroma format ('-f'
      option).

    * For PNG input, the input image is converted to the preferred
      color space ('-c' option). Its chroma is then subsampled
      according to the preferred chroma format.

    * grayscale images are kept unmodified.

- Premultiplied alpha: by default bpgenc uses non-premultiplied alpha
  to preserve the color components. However, premultiplied alpha
  ('-premul' option) usually gives a better compression at the expense
  of a loss in the color components. This loss is not an issue if the
  image is not edited.

Re: How to set encoding options for bpg delegate?

Posted: 2016-10-03T13:36:18-07:00
by dlemstra
You can modify the options in the delegates.xml file.