code: static FSImageCompression createCompression(Configuration conf, boolean forceUncompressed)
      throws IOException {
      boolean compressImage = (!forceUncompressed) && conf.getBoolean(
        HdfsConstants.DFS_IMAGE_COMPRESS_KEY,
        HdfsConstants.DFS_IMAGE_COMPRESS_DEFAULT);
  
      if (!compressImage) {
        return createNoopCompression();
      }
  
      String codecClassName = conf.get(
        HdfsConstants.DFS_IMAGE_COMPRESSION_CODEC_KEY,
        HdfsConstants.DFS_IMAGE_COMPRESSION_CODEC_DEFAULT);
      return createCompression(conf, codecClassName);
    }
docs: Create a compression instance based on the user's configuration in the given
  Configuration object.
  @throws IOException if the specified codec is not available.