DrKLO/Telegram · critical

GIF input is unsupported for legal reasons. Sorry.

Error message

GIF input is unsupported for legal reasons.  Sorry.

What it means

The jinit_read_gif function in rdgif.c is a stub that always prints this message and calls exit(EXIT_FAILURE). Although GIF_SUPPORTED is a compile-time macro, the function body contains no actual GIF decoding logic -- it is intentionally disabled for legal/licensing reasons (GIF uses LZW compression, which was historically patent-encumbered). Any attempt to read a GIF file through the cjpeg input pipeline triggers this hard exit.

Source

Thrown at TMessagesProj/jni/mozjpeg/rdgif.c:34

 *
 * We are required to state that
 *    "The Graphics Interchange Format(c) is the Copyright property of
 *    CompuServe Incorporated. GIF(sm) is a Service Mark property of
 *    CompuServe Incorporated."
 */

#include "cdjpeg.h"             /* Common decls for cjpeg/djpeg applications */

#ifdef GIF_SUPPORTED

/*
 * The module selection routine for GIF format input.
 */

GLOBAL(cjpeg_source_ptr)
jinit_read_gif(j_compress_ptr cinfo)
{
  fprintf(stderr, "GIF input is unsupported for legal reasons.  Sorry.\n");
  exit(EXIT_FAILURE);
  return NULL;                  /* keep compiler happy */
}

#endif /* GIF_SUPPORTED */

View on GitHub (pinned to 45ab8f4308)

Solutions

  1. Convert GIF images to an intermediate format (PNG, BMP, PPM) using an external tool (ImageMagick, giflib) before feeding them to cjpeg.
  2. Do not enable GIF_SUPPORTED in the build configuration unless a real GIF reader implementation is provided.
  3. If GIF input is needed, patch rdgif.c to use a real GIF decoding library (e.g., giflib) instead of the stub.

Example fix

# before
cjpeg input.gif > output.jpg
# after
convert input.gif input.png
cjpeg input.png > output.jpg
Defensive patterns

Strategy: validation

Validate before calling

# Check file type before passing to cjpeg
if file "$input" | grep -qi gif; then
  convert "$input" "${input%.*}.png"
  input="${input%.*}.png"
fi
cjpeg "$input" > output.jpg

Prevention

When it happens

Trigger: Calling jinit_read_gif() (selected as the cjpeg input module when the input file is detected as GIF), or running cjpeg on a .gif file when this mozjpeg build compiles with GIF_SUPPORTED defined but without a real GIF reader implementation.

Common situations: A build configuration that defines GIF_SUPPORTED without linking a real GIF library; attempting to convert GIF images to JPEG using cjpeg from this mozjpeg fork; automated image processing pipelines that feed GIF files into the JPEG encoder.

Related errors


AI-assisted analysis of DrKLO/Telegram@45ab8f4308 (2026-08-14). Data as JSON: /api/errors/5a132b7af10eadae. Report an issue: GitHub.