Skip to content

Unable to use flip() twice on same input #3012

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

Closed
AmeyMore98 opened this issue Dec 12, 2021 · 4 comments
Closed

Unable to use flip() twice on same input #3012

AmeyMore98 opened this issue Dec 12, 2021 · 4 comments
Labels

Comments

@AmeyMore98
Copy link

AmeyMore98 commented Dec 12, 2021

I'm using sharp(version 0.29.3), and trying to chain multiple flip() operations, but sharp applies this operation only once. I also tried disabling sharp's cache using sharp.cache(false), but it still doesn't work.
This happens for other operations also, like flop(), rotate() etc.

Here's my code:

const sharp = require("sharp");
sharp.cache(false);
sharp("/home/Downloads/temp/ip3.jpg").flip().flip().toFile("/home/Downloads/temp/op.jpg").then(console.log);

Input image:
ip3

Output image:
op

Thanks for your help!

@lovell
Copy link
Owner

lovell commented Dec 12, 2021

Yes, if you really need to do this then split the task into two pipelines.

@AmeyMore98
Copy link
Author

Ok, got it. Is this required for all operations or just flip()?
Also can you please help with some sample code or docs for the pipeline approach?
Thanks.

@lovell
Copy link
Owner

lovell commented Dec 12, 2021

If you need to repeat a given operation multiple times, yes. There's some discussion about this at #241

const flippedOnce = await sharp(input).flip().toBuffer();
const flippedTwice = await sharp(flippedOnce).flip().toBuffer();

@AmeyMore98
Copy link
Author

This works, thanks!

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

No branches or pull requests

2 participants