{"record":{"id":"519b4f2318ef0dff","repo":"Intervention/image","slug":"failed-to-apply-default-image-settings","errorCode":null,"errorMessage":"Failed to apply default image settings","messagePattern":"Failed to apply default image settings","errorType":"exception","errorClass":"DriverException","httpStatus":null,"severity":"error","filePath":"src/Drivers/Imagick/Driver.php","lineNumber":177,"sourceCode":"     *\n     * @throws DriverException\n     */\n    private function applyDefaultSettings(Imagick $imagick): Imagick\n    {\n        try {\n            $background = new ImagickPixel('rgba(255, 255, 255, 0)');\n\n            $imagick->setType(Imagick::IMGTYPE_UNDEFINED);\n            $imagick->setImageType(Imagick::IMGTYPE_UNDEFINED);\n            $imagick->setColorspace(Imagick::COLORSPACE_SRGB);\n            $imagick->setImageResolution(72, 72);\n            $imagick->setImageUnits(Imagick::RESOLUTION_PIXELSPERINCH);\n            $imagick->setImageBackgroundColor($background);\n            $imagick->setImageIterations(0);\n\n            return $imagick;\n        } catch (ImagickException | ImagickPixelException $e) {\n            throw new DriverException('Failed to apply default image settings', previous: $e);\n        }\n    }\n}\n","sourceCodeStart":159,"sourceCodeEnd":181,"githubUrl":"https://github.com/Intervention/image/blob/5598b9e39751c34afc5cdee84abef77f92c26f68/src/Drivers/Imagick/Driver.php#L159-L181","documentation":"After creating a canvas or core, Driver::applyDefaultSettings() sets defaults on the Imagick object (image type, sRGB colorspace, 72 dpi resolution, background pixel, iterations); one of those calls threw. Reached from createImage() and createCore(), this is an ImageMagick configuration/resource problem rather than bad input - the native exception is chained as previous.","triggerScenarios":"ImageMagick policy.xml restricting operations or resources so setImageResolution/setImageBackgroundColor fail; resource exhaustion when initializing huge canvases; broken builds missing color management for setColorspace(sRGB).","commonSituations":"Hardened servers with strict policy.xml; minimal container images; very large canvases after createImage() succeeded at allocation.","solutions":["Read $e->getPrevious()->getMessage() to identify which default-setting call failed","Loosen the matching ImageMagick policy.xml restriction (resource limits, coder rights)","Reduce the canvas size to confirm a resource-cap cause","Standardize/reinstall the ImageMagick build (ensure lcms2 is present for the sRGB default)"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n    $image = $manager->create($width, $height);\n} catch (\\Intervention\\Image\\Exceptions\\DriverException $e) {\n    $native = $e->getPrevious()?->getMessage() ?? 'unknown';\n    $logger->error('Default Imagick settings failed: ' . $native);\n    throw $e;\n}","preventionTips":["Audit policy.xml on hardened hosts before deploying image processing","Smoke-test canvas creation (create + encode round-trip) in environment health checks"],"tags":["imagick","initialization","settings","policy-xml","resource-limits"],"backgroundTag":"image-create-failed","analyzedSha":"5598b9e39751c34afc5cdee84abef77f92c26f68","analyzedAt":"2026-08-23T02:17:31.068Z","schemaVersion":2},"datasetVersion":"2026-08-23T08:06:27.607Z"}