{"record":{"id":"b86a8563975b98df","repo":"phacility/phabricator","slug":"this-image-is-too-large-to-transform-the-transfor","errorCode":null,"errorMessage":"This image is too large to transform. The transform limit is %s bytes, but the image size is %s bytes.","messagePattern":"This image is too large to transform\\. The transform limit is (.+?) bytes, but the image size is (.+?) bytes\\.","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"src/applications/files/transform/PhabricatorFileImageTransform.php","lineNumber":265,"sourceCode":"  }\n\n\n  /**\n   * Get the raw file data for the image being transformed.\n   *\n   * @return string Raw file data.\n   */\n  protected function getData() {\n    if ($this->data !== null) {\n      return $this->data;\n    }\n\n    $file = $this->file;\n\n    $max_size = (1024 * 1024 * 16);\n    $img_size = $file->getByteSize();\n    if ($img_size > $max_size) {\n      throw new Exception(\n        pht(\n          'This image is too large to transform. The transform limit is %s '.\n          'bytes, but the image size is %s bytes.',\n          new PhutilNumber($max_size),\n          new PhutilNumber($img_size)));\n    }\n\n    $data = $file->loadFileData();\n    $this->data = $data;\n    return $this->data;\n  }\n\n\n  /**\n   * Get the GD image resource for the image being transformed.\n   *\n   * @return resource GD image resource.\n   */","sourceCodeStart":247,"sourceCodeEnd":283,"githubUrl":"https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/files/transform/PhabricatorFileImageTransform.php#L247-L283","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Check $file->getByteSize() against 16777216 before requesting a transform, and skip (serve the original) when it exceeds the cap.","Have upstream producers downscale images below 16MB before upload.","If you truly need larger transforms, patch the constant in a fork — upstream Phabricator hard-codes it; then re-test memory_limit headroom."],"exampleFix":"// before\n$xform = PhabricatorFileTransform::getTransformByKey('thumb-140x140');\n$thumb = $file->applyTransform($xform);\n\n// after\nif ($file->getByteSize() > (1024 * 1024 * 16)) {\n  $thumb = $file; // too large to transform; use original\n} else {\n  $xform = PhabricatorFileTransform::getTransformByKey('thumb-140x140');\n  $thumb = $file->applyTransform($xform);\n}","handlingStrategy":"validation","validationCode":"if ($file->getByteSize() > (1024 * 1024 * 16)) {\n  // too large for the transform pipeline; serve original\n  return $file;\n}","typeGuard":"function isWithinTransformSizeCap(PhabricatorFile $file): bool {\n  return $file->getByteSize() <= (1024 * 1024 * 16);\n}","tryCatchPattern":null,"preventionTips":["Pre-check getByteSize() against 16MB before every transform request.","Resize large images client-side or in an upload pipeline before they are stored.","Know that the 16MB transform cap is independent of (and lower than) any upload size limit you configure."],"tags":["phabricator","image-transform","file-size","limit","php"],"backgroundTag":"file-size-limit-exceeded","analyzedSha":"5720a38cfe95b00ca4be5016dd0d2f3195f4fa04","analyzedAt":"2026-08-21T05:07:25.672Z","schemaVersion":2},"datasetVersion":"2026-08-21T13:17:26.733Z"}