phacility/phabricator · error · Exception

This image is too large to transform. The transform limit is

Error message

This image is too large to transform. The transform limit is %s bytes, but the image size is %s bytes.

What it means

PhabricatorFileImageTransform::getData() refuses to load file data for transformation when the file's byte size exceeds a hard-coded cap of 1024*1024*16 (16,777,216 bytes = 16MB). The check runs before loadFileData() so that oversized blobs are never pulled into memory for GD; both the limit and the actual size appear in the message as PhutilNumber values.

Source

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

  }


  /**
   * Get the raw file data for the image being transformed.
   *
   * @return string Raw file data.
   */
  protected function getData() {
    if ($this->data !== null) {
      return $this->data;
    }

    $file = $this->file;

    $max_size = (1024 * 1024 * 16);
    $img_size = $file->getByteSize();
    if ($img_size > $max_size) {
      throw new Exception(
        pht(
          'This image is too large to transform. The transform limit is %s '.
          'bytes, but the image size is %s bytes.',
          new PhutilNumber($max_size),
          new PhutilNumber($img_size)));
    }

    $data = $file->loadFileData();
    $this->data = $data;
    return $this->data;
  }


  /**
   * Get the GD image resource for the image being transformed.
   *
   * @return resource GD image resource.
   */

View on GitHub (pinned to 5720a38cfe)

Solutions

  1. Check $file->getByteSize() against 16777216 before requesting a transform, and skip (serve the original) when it exceeds the cap.
  2. Have upstream producers downscale images below 16MB before upload.
  3. If you truly need larger transforms, patch the constant in a fork — upstream Phabricator hard-codes it; then re-test memory_limit headroom.

Example fix

// before
$xform = PhabricatorFileTransform::getTransformByKey('thumb-140x140');
$thumb = $file->applyTransform($xform);

// after
if ($file->getByteSize() > (1024 * 1024 * 16)) {
  $thumb = $file; // too large to transform; use original
} else {
  $xform = PhabricatorFileTransform::getTransformByKey('thumb-140x140');
  $thumb = $file->applyTransform($xform);
}
Defensive patterns

Strategy: validation

Validate before calling

if ($file->getByteSize() > (1024 * 1024 * 16)) {
  // too large for the transform pipeline; serve original
  return $file;
}

Type guard

function isWithinTransformSizeCap(PhabricatorFile $file): bool {
  return $file->getByteSize() <= (1024 * 1024 * 16);
}

Prevention

When it happens

Trigger: Any image transform (thumbnail, profile crop, etc.) on a file whose getByteSize() is > 16MB — e.g. raw camera photos or 'image/png' exports attached via drag-and-drop, then rendered somewhere that requests a thumbnail.

Common situations: Users attaching full-resolution photos or scans; raising file upload limits without realizing the transform pipeline has its own fixed 16MB cap; files whose declared MIME type is an image type but whose content is huge regardless.

Related errors


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