Skip to content
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

feature request: lqip #27

Closed
eleith opened this issue Jul 16, 2018 · 4 comments
Closed

feature request: lqip #27

eleith opened this issue Jul 16, 2018 · 4 comments
Labels
enhancement New feature or request
Milestone

Comments

@eleith
Copy link
Contributor

eleith commented Jul 16, 2018

using something like lqip, i think it would be useful to import and image and request a low quality image placeholder to be generated (or to just extract the dominant color instead).

you likely could use these loaders independently, but i like the decision of this library to use url query params to drive signaling of intent on how to handle the image and i could imagine a ?lqip or ?lqip-dominant-color as extensions of this module.

for now, i'm just generating these myself, but in the spirit of DRY, this might be a useful direction to consider. i'ld be interested if you felt the same way or had previously considered and rejected the idea.

@cyrilwanner
Copy link
Owner

Thank you for the feature request @eleith, I really like this idea. For me, this is also a part of image/performance optimization and I think it will fit well into this package (as we already generate webp on the fly for example).

I'm planning to rewrite this package (as it grew larger than expected and to be able to handle exactly the resource queries better) and release version 2 within the next few weeks. The plan is that all optimizations will be optional and when someone wants to use a specific optimization (like webp or lqip), he then just can install the required npm dependency and use the resource query provided by this package.
Image optimization packages are often big and require native binaries which not everyone uses in the end so this will also reduce installation time and fix some possible issues in CI/CD environments. img-loader (which next-optimized-images depends on) also went into the same direction.

Long story short, I'll add this optimization in version 2 :) I hope generating them for yourself still works in the meantime, I'll definitely keep you posted on this topic.
Also, feel free to comment here or open new issues if you have more ideas for improvements :)

@cyrilwanner cyrilwanner added the enhancement New feature or request label Jul 17, 2018
@cyrilwanner cyrilwanner added this to the 2.0 milestone Jul 17, 2018
@eleith
Copy link
Contributor Author

eleith commented Jul 17, 2018

thank you for the revealing response =]

this has been a great library to work with. both in terms of using it to solve a very focused problem with web development in nextjs but also as a pattern for solving similar problems (i used your pattern to deal with serving fonts locally by using the file loader to both rename and copy them to an internal _next folder)

anyhow, the roadmap looks great. i will be both happy to use it and customize it for some problems i am particularly interested in (resizing of images, auto LQIP production, etc etc)

@cyrilwanner
Copy link
Owner

Hey @eleith
Unfortunately, it took me way longer to create v2 and implement this feature than I expected at first and I'm sorry about that (there were some other projects which came into my way).

But I now implemented LQIP into v2.1.0 as an optional package.
So if you are on version 2.1.0, you can simply run npm install lqip-loader and then just use the resource query, next-optimized-images automatically detects the installed package. (If you are on v1.x, please read the upgrade guide to v2 first as there were some breaking changes)

There are now two additional resource queries: ?lqip and ?lqip-colors.

I would be happy if you can test it sometime and give feedback if it works as you expected it :)

Example implementation:

export default () => (
	<div>
		<img src={require('./images/lqip-test.jpg?lqip')} />
		<Palette colors={require('./images/lqip-test.jpg?lqip-colors')} />
	</div>
);

image

@eleith
Copy link
Contributor Author

eleith commented Jan 17, 2019

trying it out right now and am happy with the results.

upgrading to v2 was fairly straight forward and i'll be slowly replacing my custom lqip with these. i like how the lqip image is inlined when the image is small.

i likely will need to use the css blur effect to make it look less blocky, but that is a concern of how the browser stretches out tiny images.

thanks again for taking on the rewrite and improving this library even more.

@eleith eleith closed this as completed Jan 17, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants