{"record":{"id":"48a45d283f8fc43d","repo":"phacility/phabricator","slug":"error-when-decoding-image","errorCode":null,"errorMessage":"Error when decoding image.","messagePattern":"Error when decoding image\\.","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"src/applications/files/storage/PhabricatorFile.php","lineNumber":1120,"sourceCode":"      throw new Exception(pht('Cannot retrieve image information.'));\n    }\n\n    if ($this->getIsChunk()) {\n      throw new Exception(\n        pht('Refusing to assess image dimensions of file chunk.'));\n    }\n\n    $engine = $this->instantiateStorageEngine();\n    if ($engine->isChunkEngine()) {\n      throw new Exception(\n        pht('Refusing to assess image dimensions of chunked file.'));\n    }\n\n    $data = $this->loadFileData();\n\n    $img = @imagecreatefromstring($data);\n    if ($img === false) {\n      throw new Exception(pht('Error when decoding image.'));\n    }\n\n    $this->metadata[self::METADATA_IMAGE_WIDTH] = imagesx($img);\n    $this->metadata[self::METADATA_IMAGE_HEIGHT] = imagesy($img);\n\n    if ($save) {\n      $this->save();\n    }\n\n    return $this;\n  }\n\n  public function copyDimensions(PhabricatorFile $file) {\n    $metadata = $file->getMetadata();\n    $width = idx($metadata, self::METADATA_IMAGE_WIDTH);\n    if ($width) {\n      $this->metadata[self::METADATA_IMAGE_WIDTH] = $width;\n    }","sourceCodeStart":1102,"sourceCodeEnd":1138,"githubUrl":"https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/files/storage/PhabricatorFile.php#L1102-L1138","documentation":"Error \"Error when decoding image.\" thrown in phacility/phabricator.","triggerScenarios":"Thrown at src/applications/files/storage/PhabricatorFile.php:1120 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"5720a38cfe95b00ca4be5016dd0d2f3195f4fa04","analyzedAt":"2026-08-21T05:07:25.672Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}