# Summary
ImageAPI Optimize allows you to use your preferred toolkit and optimize (losslessly) the image when it is saved. Practice for web performance suggests that images should be optimized for better loading time. With this module enabled, Google's Page Speed will always give you an A in image optimize.
# Project URL
https://www.drupal.org/project/imageapi_optimize
# Where is the code?
https://www.drupal.org/sandbox/darthsteven/2614582
# Estimated completion date
Unknown
# Dependencies
Drupal 8.2.x
# Who's doing the port?
# What help do they need?
N/A
# D8 roadmap
This issue is tracking the stuff needed for a minimum viable port: #2797219: [meta] Drupal 8 port
Comments
Comment #2
steven jones commentedHi, if we're interested in porting this module to Drupal 8, how should we get involved?
Wondering if I could get commit access to start a new branch of work or if I should start in a sandbox/github?
Comment #3
jcisio commentedHi Steven,
You could start in a sandbox or Github as you prefer, and when you think it's ready, post as a patch. I'll then review and add you as maintainer of 8.x branch.
Comment #4
luksakHas anyone started working on this port?
Comment #5
steven jones commentedI've not started working on it, but have had some thoughts :)
Shall we get a sandbox repo somewhere spun up to work on it.
I suspect that we'll just want to start from scratch given the extensive changes to Drupal rather than doing a 'straight port'.
Comment #6
luksakYes, makes sense. Do you have time to work on it? I would provide testing, feedback and patches.
Comment #7
steven jones commentedSo I have a fork of ImageAPI Optimize that does the following:
Some of that in D7 is a touch hacky :) But it does work, and gives a nice amount of flexibility, for example, I can configure one image style to have lossy compression, and another to have lossless compression, and another to not have any at all.
Thinking about the architecture of the Drupal 8 module, I feel that there should be two streams of work here:
Does that sound sensible?
When I was doing my D7 port, I copied and renamed image styles/effects to pipelines/processors. I think we could essentially do the same here to get a D8 port.
Image styles have a number of effects on them with config, and likewise, pipelines should have a number of processors on them with config. So architecturally I think we can just copy core here.
As for point 2, if we want to provide our pipelines as 'toolkits' that can be swapped out wholesale, then it's kinda easy, we just need to provide our own plugin and wire it all up. Easy.
If we wanted to go the route of changing and image style to have an 'optimization pipeline', then I reckon we could do this via:
hook_entity_type_alterand swap out the base image style class for one of our own.createDerivativemethod.I'd argue for shooting for the swapping out the ImageStyle class for our own, it will get us a lovely amount of flexibility :)
Comment #8
luksakThank you for your thoughts! Sounds good :)
Having two ways of using the optimizations as wholesale and being able to define them on a image style basis makes sense. I'd suggest to go for an MVP which provides the wholesale functionality first since this is the more common use case I guess.
In general I have to say that I am not too familiar with the way the image generation process works in general. One important thing to me would be the ability to choose the image toolkit independent of the optimization. The user has to be able to choose between GD and ImageMagick alongside the optimization settings.
I can't really judge which approach to take on the per image style solution. Can anyone else provide feedback on this?
Comment #9
steven jones commentedSome progress in my fork.
I've got a rough implementation that vaguely works in Drupal 8.2.x :)
Resmush.it integration is working, though I then tried to make it configurable, and that's broken again now.
When for the all-singing all-dancing approach of making it configurable per image style, which was actually quite easy.
Comment #10
steven jones commentedComment #11
luksakOh nice! About to test it on the current project. I will provide feedback asap.
Comment #12
steven jones commentedIt'll be very much broken at the moment I suspect, be warned!
Comment #13
steven jones commentedComment #14
steven jones commentedComment #15
luksakI have a first feedback: please add a
composer.jsonso I can install the module using composer.Comment #16
luksakWhen adding a processor to a pipeline I get the following error:
Comment #17
luksakBTW, all my reports will be in 8.2.0-RC1.
Comment #18
steven jones commented@Lukas von Blarer I've just addressed those two issues. Not 100% sure what should go in the composer.json so just put something vaguely sensible in there for now.
Comment #19
steven jones commentedI've added some child tickets to #2797219: [meta] Drupal 8 port for a minimum viable port to D8.
Comment #20
steven jones commentedSetting to 'Needs review' as I think I've not pushed the basics of a D8 port into place.
Still some cleanup of docs to do, and need to get stuff that wasn't in D7 into D8 (like some tests).
Comment #21
steven jones commentedComment #22
steven jones commentedNow that I have something worthy of becoming the Drupal 8 branch, I've asked for maintainer access in #2805805: Request for maintainer access
Comment #23
jcisio commentedWe have releases for D8, so marking this issue as fixed and work will continue on the project issue queue.
Comment #25
benjifisherAccording to https://www.drupal.org/project/contrib_tracker#statuses this issue should be marked "Needs Review" since it has an alpha (or beta) release, but not a stable one.
I do not have permission to change the status from Closed to NR.
Comment #26
Anonymous (not verified) commentedThe 2.0-alpha1 works great!
Integration with the imagemagick module would be nice... e.g. choosing between GD and imagemagick on the image toolkit page, like in the D7 version.
Thanks a lot!
Comment #27
steven jones commented@agx the Drupal 8 version of the module should integrate just fine with GD or ImageMagick. As it's now not a image toolkit, it can be applied totally independently.