Intervention/image · error · DriverException
Failed to get frame size
Error message
Failed to get frame size
What it means
Frame::size() wraps getImageWidth()/getImageHeight() (src/Drivers/Imagick/Frame.php:90-93) and re-throws any ImagickException as DriverException. These getters only fail when the underlying Imagick object is in an invalid state — typically cleared/destroyed, or holding a failed decode — so the actionable detail is in the previous exception.
Source
Thrown at src/Drivers/Imagick/Frame.php:95
return $this->native;
}
/**
* {@inheritdoc}
*
* @see DriverInterface::size()
*
* @throws DriverException
*/
public function size(): SizeInterface
{
try {
return new Size(
$this->native->getImageWidth(),
$this->native->getImageHeight(),
);
} catch (ImagickException | InvalidArgumentException $e) {
throw new DriverException('Failed to get frame size', previous: $e);
}
}
/**
* {@inheritdoc}
*
* @see DriverInterface::delay()
*
* @throws DriverException
*/
public function delay(): float
{
try {
return $this->native->getImageDelay() / 100;
} catch (ImagickException $e) {
throw new DriverException('Failed to get frame delay', previous: $e);
}
}View on GitHub (pinned to 5598b9e397)
Solutions
- Inspect $e->getPrevious()->getMessage() for the native ImageMagick error
- Do not clear()/destroy a native you hand back to the library; clone before manual teardown
- Re-read the image from the original source when pipeline state is uncertain
- Abort the whole operation instead of continuing after a caught Imagick error
Example fix
// before $imagick->clear(); $size = $frame->size(); // native already freed // after $size = $frame->size(); $imagick->clear();
Defensive patterns
Strategy: try-catch
Try / catch
use Intervention\Image\Exceptions\DriverException;
try {
$size = $frame->size();
} catch (DriverException $e) {
$reason = $e->getPrevious()?->getMessage() ?? $e->getMessage();
if (str_contains(strtolower($reason), 'no image loaded') || str_contains($reason, 'destroyed')) {
// core was cleared: recover by re-reading the source
$image = $manager->read($sourcePath);
$size = $image->frames()->first()->size();
} else {
throw $e;
}
} Prevention
- Never call clear()/destroy() on natives still owned by the library; clone first
- Treat any caught Imagick error as fatal for that image; do not continue the pipeline
- Keep frame references only within the modifier that produced them
When it happens
Trigger: Calling size() (or modifiers such as resize/crop that query frame size) after the native Imagick was clear()ed/destroyed; using a Frame whose native came from an aborted decode; double-processing an already-freed core.
Common situations: Custom modifiers that call $imagick->clear() and then let the library continue; caching Frame/Core objects beyond their lifetime; swallowing an earlier exception and continuing the pipeline on a broken core.
Related errors
- Failed to get frame delay
- Failed to create instance of Intervention\Image\Drivers\Imag
- Value for argument setNative() "$native" must be instanceof
- Failed to set frame disposal method
- Given color space must implement Intervention\Image\Interfac
AI-assisted analysis of Intervention/image@5598b9e397 (2026-08-23).
Data as JSON: /api/errors/b9c18917ef739ed5.
Report an issue: GitHub.