-
-
Notifications
You must be signed in to change notification settings - Fork 25
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
Add progress information #63
Labels
enhancement
New feature or request
Milestone
Comments
Good idea! I just implemented this with commit c004099, allowing you to do this: // Load a huge image
const im = vips.Image.black(100000, 100000);
// Attach progress feedback
let lastPercent = 0;
im.onProgress = (percent) => {
// This callback is triggered once per work unit (typically a 128 x
// 128 area of pixels) during image computation. Therefore, we only
// need to print when there's a change in the percentage.
if (percent !== lastPercent) {
console.log(`${percent}% complete`);
lastPercent = percent;
}
// To stop long-running computations, we could block evaluation after a
// certain amount of time. To avoid complexity in this example, issue the
// kill signal after 25% completion.
if (percent >= 25) {
im.kill = true;
}
};
// Save
im.writeToFile('x.png'); I also made it possible to stop long-running computations with commit 20f8414, as shown in the example above. This will be in v0.0.8. |
This is fantastic, thanks a lot for this fast response & implementation! Looking forward to implementing both in my project. |
This was referenced Jan 29, 2024
v0.0.8 is now available with these improvements. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
On the command line
--vips-progress
runs a progress indicator during computation. It can be useful to see where libvips is looping and how often.I wonder if it's possible to expose progress in a similar way in wasm-vips, for example by adding an option to provide a callback function that gets called with the current progress. That way, if an operation takes a bit longer, one can display a progress bar to users as well.
The text was updated successfully, but these errors were encountered: