-
Notifications
You must be signed in to change notification settings - Fork 66
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RFC Default to Imagick over GD when available #207
Comments
Also could consider adding Another possible option could be to make the SilverStripe\Core\Injector\Injector:
Intervention\Image\ImageManager:
constructor:
- drivers: [ imagick, gd ] That would move the default backend out of the code to the configuration level. |
I've just swapped the driver to imagick on a site that receives constant updates and saw a 50% speedup across the board in site load speed time. I can't upvote the suggestion enough! Really didn't expect this much of a difference |
I think this is well worth doing. Changing defaults for configuration is not allowed under our definition of public API - we could opt into this for new projects by adding config to installer, or we could just have this as a CMS 6 enhancement. |
A couple extra notes.
Looking at this now, I don't know that we have to provide any option. Basically, the factory would be used by default. If you want to explicitly use GD or Imagick, just use the Injector to instantiate your own. In YML this would look like this. ## Default set up
SilverStripe\Core\Injector\Injector:
Intervention\Image\ImageManager:
factory: SilverStripe\Assets\ImageManagerFactory
## Snippet to copy in your project if you GD
SilverStripe\Core\Injector\Injector:
Intervention\Image\ImageManager:
constructor:
- { driver: gd }
## Snippet to copy in your project if you Imagick
SilverStripe\Core\Injector\Injector:
Intervention\Image\ImageManager:
constructor:
- { driver: imagick } My current assumption is that figuring out if the current server supports Imagic is a trivial process that takes a negligible amount of time. I would like that assumption validated. |
The way we tend to do it currently is with a check to see whether the extension is loaded ---
Only:
extensionloaded: imagick
---
SilverStripe\Core\Injector\Injector:
Intervention\Image\ImageManager:
constructor:
- { driver: imagick } |
@jeremysomar Didn't think about that. That's actually a lot more straight forward. |
Since this is for CMS 6, and we need to upgrade to intervention 3 for CMS 6 (intervention 2 is EOL), we need to do this issue to upgrade to intervention 3 before doing this one. The API for intervention 3 is very different from intervention2 |
This will be done as part of #619, since I need to add yaml config to define the default driver anyway as part of the upgrade. |
Background
I've been working on silverstripe/silverstripe-framework#8664 which indirectly led me to compare the performance of GD vs Imagick.
Our current ImageManager defaults to using GD as its driver. Developers can decide to use Imagick by adding this in their config.
On my test case, Imagick is orders of magnitude faster than GD. When generating thumbnails for a thousand 4K image a got the following performance:
Both were using about the same amount of memory.
GD is bundled with PHP so we can be rely on it being available. Imagick needs to be installed by your sysadmin, but many hosting environment will have it pre-installed.
My assumptions are that
Proposal
ImageManagerFactory
that accepts three possible driver:gd
,imagick
orauto
which would test for the availability of Imagick fallback to GD.ImageManagerFactory
, so people would get the performance boost simply by upgrading.ImageManagerFactory
in its YML config, so only new project would get it by default.Things to keep in mind
Acceptance criteria
The text was updated successfully, but these errors were encountered: