phacility/phabricator · error · Exception

Error when decoding image.

Error message

Error when decoding image.

What it means

Decode failure in updateDimensions: GD's imagecreatefromstring() returned false — the loaded bytes are not a decodable image (corrupt, truncated, or an unsupported/oversized format), even though the MIME type claimed viewability.

Solutions

  1. Verify the file bytes are a complete, valid image
  2. Check MIME type detection isn't mislabeling non-image data as viewable
  3. Handle very large images that GD refuses due to memory/scale limits
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at src/applications/files/storage/PhabricatorFile.php:1120 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of phacility/phabricator@5720a38cfe (2026-08-21). Data as JSON: /api/errors/48a45d283f8fc43d. Report an issue: GitHub.

Appendix: source

Thrown at src/applications/files/storage/PhabricatorFile.php:1120

      throw new Exception(pht('Cannot retrieve image information.'));
    }

    if ($this->getIsChunk()) {
      throw new Exception(
        pht('Refusing to assess image dimensions of file chunk.'));
    }

    $engine = $this->instantiateStorageEngine();
    if ($engine->isChunkEngine()) {
      throw new Exception(
        pht('Refusing to assess image dimensions of chunked file.'));
    }

    $data = $this->loadFileData();

    $img = @imagecreatefromstring($data);
    if ($img === false) {
      throw new Exception(pht('Error when decoding image.'));
    }

    $this->metadata[self::METADATA_IMAGE_WIDTH] = imagesx($img);
    $this->metadata[self::METADATA_IMAGE_HEIGHT] = imagesy($img);

    if ($save) {
      $this->save();
    }

    return $this;
  }

  public function copyDimensions(PhabricatorFile $file) {
    $metadata = $file->getMetadata();
    $width = idx($metadata, self::METADATA_IMAGE_WIDTH);
    if ($width) {
      $this->metadata[self::METADATA_IMAGE_WIDTH] = $width;
    }

View on GitHub (pinned to 5720a38cfe)