- What is intervention/gif and how do I install it in Laravel?
- Intervention GIF is a native PHP encoder and decoder for the GIF image format. Install it with composer require intervention/gif; it is framework-agnostic and ships without a Laravel service provider or config. The core decode and encode paths do not need GD or Imagick, but PHP 8.3 or newer is required.
- Does intervention/gif require GD or Imagick?
- No, not for the core encode and decode path. Decoder and Builder work without GD or Imagick; only the Splitter class requires GD because it returns each frame as a GDImage object. That makes the library usable in restricted or serverless runtimes where image extensions are unavailable, unless you need per-frame pixel manipulation.
- Which Laravel and PHP versions support intervention/gif?
- The hard requirement is PHP 8.3 or newer, which is the main feasibility gate. It works on Laravel 11 and 12, and on Laravel 10 where the runtime is already PHP 8.3. It will block services still on PHP 8.1 or 8.2 until those platforms are upgraded.
- How do I decode a GIF file or binary string in Laravel?
- Use Decoder::decode() with either a file path or raw binary contents. It returns an Intervention\Gif\GifDataStream model, not a Laravel response or facade. In Laravel you would call it from a controller, job, or a small service class you bind yourself, then inspect or re-encode the stream.
- How do I create an animated GIF with per-frame delays and offsets?
- Create a canvas with Builder::canvas(width: 32, height: 32), then call addFrame() for each frame. addFrame accepts the frame path, a delay in seconds, and optional left and top offsets; setLoops() controls repetition, with 0 meaning infinite. Finish with encode() to get the GIF binary data.
- How can I split an animated GIF into individual frames?
- Use the Splitter class, which divides an animated GIF data stream into individual frames. Because each frame is returned as a GDImage object, Splitter is the one part of the package that requires the GD extension. Everything else can decode and re-encode without GD or Imagick.
- Is there a Laravel service provider, config file, or facade for intervention/gif?
- No. The package is framework-agnostic and does not ship a service provider, config file, facade, or storage assumptions. You own the Laravel integration layer, such as container bindings and a Gif facade, which is a small but deliberate piece of work. That also means there are no package config values to publish.
- Can intervention/gif convert video to GIF or apply advanced animation effects?
- No, that is outside its scope. Intervention GIF decodes, builds, and encodes GIF data, including animated frames, delays, offsets, and loop counts. Video-to-GIF conversion needs FFmpeg and should be scoped separately; advanced compression and complex animation effects are also not part of this library.
- How should I validate uploaded GIFs and handle large files with intervention/gif?
- The package does not ship Laravel validation rules or hard limits for dimensions, frame count, file size, or loop count. You should build a shared validation layer and enforce those limits before decoding, especially for untrusted uploads. Also treat whole-stream decoding of large GIFs as a memory concern rather than a CPU concern, and sandbox or cap inputs accordingly.
- Is intervention/gif actively maintained, and what alternatives should I consider?
- It is a small, focused library maintained by olivervogel and used as the animated-GIF engine inside Intervention Image. Recent releases have addressed corrupted or truncated input and loop-count ambiguity, but it is still a single-maintainer project rather than a vendor-backed platform. Verify the latest Packagist release cadence before committing to a support posture, and keep a thin adapter if you want a low-cost exit path to Imagick-based or other alternatives.