-
Notifications
You must be signed in to change notification settings - Fork 15
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
Added support for custom image loaders #14
base: master
Are you sure you want to change the base?
Conversation
Rather than letting the library directly read from files and io.Readers backed by http it now has support for custom loaders. You will have to implement the ImageLoader() (image.Image, error) interface from now on. This allows you to be in control yourself over where you load your image from, how you cache it, etc. For GIF support you'll have to implement the Gif() (*gif.GIF, error) interface next to the ImageLoader interface. For backwards compatibility I added a couple of loaders already, the FileImage, HttpImage. The main program should still function as originally.
@muesli since you are the first 3rd party consumer of this API could you review this PR to confirm it meets what your use case for glow? |
I think I would have just gone for an |
Now that I look at it again I should probably have made the |
Understood. I'll quickly whip up an example with a simple io.Reader approach for comparison. |
Here it is: #15 |
Just as a heads up: I skipped the other improvements @schoentoon introduced. Nice work there, I'm all for them! |
@schoentoon You got some gnarly conflicts at the moment. For this to get merged. Changes I'd like to see:
I have some bandwidth this weekend to push this forward if you are swamped. |
TIL |
@schoentoon Yeah, it's all conventions, but I guess it makes sense to stick to the established ones. Sorry for causing the merge conflicts here, but I hope you can see why using the existing For this reason I think we should try not to introduce an |
I would argue that being able to provide a |
Took a bit longer than I expected. I ended up going for a whole interface around it, which you can implement yourself in any way you'd like.