Skip to content

Add GIF input support - #360

Open
ShaiMagal wants to merge 1 commit into
rosell-dk:masterfrom
ShaiMagal:add-gif-support
Open

Add GIF input support#360
ShaiMagal wants to merge 1 commit into
rosell-dk:masterfrom
ShaiMagal:add-gif-support

Conversation

@ShaiMagal

Copy link
Copy Markdown

Add GIF input support

This adds image/gif as a supported source type, so GIF images can be converted to WebP the same way PNG and JPEG already are.

Changes

  • InputValidator – allow image/gif through the input mime-type gate
  • Gd – load the source via imagecreatefromgif(), with the usual "compiled without GIF support" availability check
  • Imagick / Gmagick – accept image/gif (checks that GIF is present in queryFormats())
  • OptionsTrait – support a gif option group, mirroring the existing png / jpeg groups

Notes / limitations

  • Animated GIFs are converted to a single (first) frame static WebP – this matches GD's imagecreatefromgif() behaviour.
  • For option handling, GIF currently falls into the same default option group as JPEG (the $imageType ternary in OptionsTrait::setProvidedOptions()), in addition to the dedicated gif group added here. Happy to switch GIF to the PNG/lossless path instead if you'd prefer.

Real-world use

This patch has been running in production for a while as part of a PrestaShop WebP module, converting user-uploaded GIFs without issues.

Adds image/gif as a supported source type, so GIF images can be
converted to WebP the same way PNG and JPEG already are.

- InputValidator: allow image/gif through the input mime-type gate
- Gd: load via imagecreatefromgif() + availability check
- Imagick / Gmagick: accept image/gif (GIF in queryFormats())
- OptionsTrait: support a gif option group (mirrors png / jpeg)

Animated GIFs are converted to a single (first) frame static WebP,
matching GD's imagecreatefromgif() behaviour.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant