{"record":{"id":"b4218869df85632e","repo":"Intervention/image","slug":"failed-to-apply-class-unable-to-insert-watermar","errorCode":null,"errorMessage":"Failed to apply {class}, unable to insert watermark image","messagePattern":"Failed to apply (.+?), unable to insert watermark image","errorType":"exception","errorClass":"Intervention\\Image\\Exceptions\\ModifierException","httpStatus":null,"severity":"error","filePath":"src/Drivers/Imagick/Modifiers/InsertModifier.php","lineNumber":70,"sourceCode":"                );\n            } catch (RuntimeException $e) {\n                throw new ModifierException(\n                    'Failed to apply ' . self::class . ', unable to set transparency of watermark',\n                    previous: $e,\n                );\n            }\n        }\n\n        foreach ($image as $frame) {\n            try {\n                $result = $frame->native()->compositeImage(\n                    $watermark->core()->native(),\n                    Imagick::COMPOSITE_DEFAULT,\n                    $position->x(),\n                    $position->y(),\n                );\n                if ($result === false) {\n                    throw new ModifierException(\n                        'Failed to apply ' . self::class . ', unable to insert watermark image',\n                    );\n                }\n            } catch (ImagickException $e) {\n                throw new ModifierException(\n                    'Failed to apply ' . self::class . ', unable to insert watermark image',\n                    previous: $e,\n                );\n            }\n        }\n\n        return $image;\n    }\n}\n","sourceCodeStart":52,"sourceCodeEnd":85,"githubUrl":"https://github.com/Intervention/image/blob/5598b9e39751c34afc5cdee84abef77f92c26f68/src/Drivers/Imagick/Modifiers/InsertModifier.php#L52-L85","documentation":"This ModifierException is thrown by $image->insert() when compositing the watermark onto the base image fails with a false return. For every frame the driver calls compositeImage($watermarkNative, Imagick::COMPOSITE_DEFAULT, $x, $y); a false return is reported as 'unable to insert watermark image' with no chained previous exception, meaning ImageMagick declined the composite in this environment.","triggerScenarios":"Calling $image->insert($source, ...) with watermark dimensions exceeding ImageMagick's resource limits (policy.xml width/height/area caps); compositing onto corrupted frames; environments where the composite operation is policy-restricted; watermark/base combinations (e.g. extreme bit depths) unsupported by the installed build.","commonSituations":"Inserting large print-resolution watermarks on shared hosting; policy.xml capping dimensions below the asset sizes; batch pipelines processing truncated uploads; minimal Docker ImageMagick configurations.","solutions":["Downscale watermark or base image and retry to confirm a resource-limit cause","Inspect and raise width/height/area limits in /etc/ImageMagick-*/policy.xml","Re-encode suspicious base images or watermarks to clean PNG/JPEG","Update ImageMagick and the imagick extension","If the environment cannot be changed, perform insertion with the GD driver instead"],"exampleFix":"// before\n$image->insert('huge-logo.png', 'center'); // 12000px logo, policy caps area\n\n// after\n$logo = $manager->read('huge-logo.png')->scaleDown(width: 2000);\n$image->insert($logo, 'center');","handlingStrategy":"try-catch","validationCode":"$watermark = $manager->read($watermarkPath);\nif ($watermark->width() * $watermark->height() > 4_000_000) {\n    $watermark->scaleDown(width: 2000);\n}\n$image->insert($watermark, 'center');","typeGuard":null,"tryCatchPattern":"use Intervention\\Image\\Exceptions\\ModifierException;\n\ntry {\n    $image->insert($wm, 'center');\n} catch (ModifierException $e) {\n    Log::warning('Composite returned false: ' . optional($e->getPrevious())->getMessage());\n    throw $e;\n}","preventionTips":["Downscale watermarks and base images below policy.xml dimension/area caps","Re-encode untrusted sources before compositing","This variant has no previous exception — suspect resource limits first","Run `magick -list resource` on hosts where composites intermittently fail"],"tags":["intervention-image","imagick","watermark","composite","insert","resource-limits","php"],"backgroundTag":"imagick-composite-failed","analyzedSha":"5598b9e39751c34afc5cdee84abef77f92c26f68","analyzedAt":"2026-08-23T02:17:31.068Z","schemaVersion":2},"datasetVersion":"2026-08-23T08:06:27.607Z"}