phacility/phabricator · error · Exception

This image (with dimensions %spx x %spx) is too large to tra

Error message

This image (with dimensions %spx x %spx) is too large to transform. The image has %s pixels, but transforms are limited to images with %s or fewer pixels.

What it means

The pre-flight dimension check computed width*height and found more pixels than the hard cap of 4096*4096 = 16,777,216 pixels. This bounds the memory GD would need to decode the bitmap (each pixel costing several bytes in both source and destination buffers). The message includes the dimensions, the pixel count, and the cap as formatted numbers.

Source

Thrown at src/applications/files/transform/PhabricatorFileImageTransform.php:337

    if ($info === false) {
      throw new Exception(
        pht(
          'Unable to get image information with getimagesize(): %s',
          $errors));
    }

    list($width, $height) = $info;
    if (($width <= 0) || ($height <= 0)) {
      throw new Exception(
        pht(
          'Unable to determine image width and height with getimagesize().'));
    }

    $max_pixels = (4096 * 4096);
    $img_pixels = ($width * $height);

    if ($img_pixels > $max_pixels) {
      throw new Exception(
        pht(
          'This image (with dimensions %spx x %spx) is too large to '.
          'transform. The image has %s pixels, but transforms are limited '.
          'to images with %s or fewer pixels.',
          new PhutilNumber($width),
          new PhutilNumber($height),
          new PhutilNumber($img_pixels),
          new PhutilNumber($max_pixels)));
    }

    $trap = new PhutilErrorTrap();
    $image = @imagecreatefromstring($data);
    $errors = $trap->getErrorsAsString();
    $trap->destroy();

    if ($image === false) {
      throw new Exception(
        pht(

View on GitHub (pinned to 5720a38cfe)

Solutions

  1. Downscale uploads before they reach Phabricator (client-side resize, or an upload pipeline step) so images stay at or under 4096x4096.
  2. Skip transforms for oversized images and serve the original file.
  3. If policy allows, patch the $max_pixels constant in a fork — but first confirm PHP memory_limit can absorb decoding such images.

Example fix

// before
$thumb = $file->applyTransform($xform); // throws on 6000x4000 photo

// after
$info = @getimagesize($file->getURI());
if ($info && ($info[0] * $info[1]) > (4096 * 4096)) {
  $thumb = $file; // too many pixels; serve original
} else {
  $thumb = $file->applyTransform($xform);
}
Defensive patterns

Strategy: validation

Validate before calling

$info = @getimagesize($file->getURI());
if ($info && ($info[0] * $info[1]) > (4096 * 4096)) {
  return $file; // over pixel cap; serve original instead of transforming
}

Type guard

function isWithinTransformPixelCap(array $info): bool {
  return ($info[0] * $info[1]) <= (4096 * 4096);
}

Prevention

When it happens

Trigger: Transforming any image larger than 4096x4096 pixels — e.g. 6000x4000 camera JPEGs, stitched panoramas, high-resolution scans, or large design exports — once a thumbnail or crop transform is requested.

Common situations: Modern phone camera defaults (12-50MP) exceed the cap outright; users exporting print-resolution PNGs; galleries that request thumbnails for every upload, hitting the cap on the first render of a large photo.

Related errors


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