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 - Add support of Image operation for sharp adapter #70

Open
Ngob opened this issue Sep 21, 2018 · 5 comments
Open

Feature Request - Add support of Image operation for sharp adapter #70

Ngob opened this issue Sep 21, 2018 · 5 comments

Comments

@Ngob
Copy link

Ngob commented Sep 21, 2018

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).

@evdama
Copy link

evdama commented Dec 6, 2018

good stuff; want!
do we have a pending PR for this?

@jstcki
Copy link
Contributor

jstcki commented Dec 6, 2018

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()
  }
}

@Ngob
Copy link
Author

Ngob commented Dec 6, 2018

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.

@strarsis
Copy link

strarsis commented Apr 6, 2019

@Ngob: Does this loader with sharp support cropping currently?

@Ngob
Copy link
Author

Ngob commented Apr 26, 2019

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants