responsive-loader
responsive-loader copied to clipboard
Feature Request - Add support of Image operation for sharp adapter
Hello,
Sharp allowing the possibility of extract an image (a crop) using http://sharp.pixelplumbing.com/en/stable/api-operation/#extract. Does it make sense to add it to this package? With this, it would be nice to be able to chain images transformation, with something like:
use: [
{
loader: 'file-loader',
}
{
loader: 'responsive-loader',
options: {
adapter: require('responsive-loader/sharp-extract'),
name: "images/responsive/[name]-[width].[ext]"
}
},
{
loader: 'responsive-loader',
options: {
adapter: require('responsive-loader/sharp')
}
},
],
this way, we can resize then extract the image (looks like another feature request).
good stuff; want! do we have a pending PR for this?
Not sure if it's possible/necessary to chain loaders for this. How about something like
{
loader: 'responsive-loader',
options: {
adapter: require('responsive-loader/sharp'),
operations: [["rotate", 90], "extract"]
}
}
// Or even better?
{
loader: 'responsive-loader',
options: {
adapter: require('responsive-loader/sharp'),
operations: img => img.rotate(90).extract()
}
}
That do not work in my case, I need to be able to configure it inline: asset.jpg?size=1200&extract_left=151&extract_top=0&extract_width=1200
, except if img
contains his own query?
For information, I think you are right, I tried to chain it properly but it did not work, I will retry it asap and open an according PR if it works.
@Ngob: Does this loader with sharp support cropping currently?
@strarsis not as it is. I modified code to allow cropping, but it work only with inline queries and you can not crop and resize the same image. I can share the code if you like.