Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Image.SetKill(true) does not work on DzSave

See original GitHub issue

I am having trouble aborting a DzSave call.

Sample Code:

using NetVips;


// setup parameters
var testImage = @"sample_640×426.tif";
var savePath = "output";
var saveName = savePath + "/" + "testPyramid";

if (!Directory.Exists(savePath))

// open image
using var image = Image.NewFromFile(testImage);

// start creation of pyramid in background task
VipsException? vipsException = null;
var createPyramidTask = Task.Run(() =>
            image.Dzsave(filename: saveName,
                tileSize: 10,
                overlap: 0,
                suffix: ".tif",
                depth: Enums.ForeignDzDepth.Onetile
        catch (VipsException ex)
            vipsException = ex;

var start = DateTime.Now;

// wait one second and set kill flag. Wait until task returns.
await Task.Run(async () =>

    while (DateTime.Now - start < TimeSpan.FromSeconds(2))

    Console.WriteLine("killflag set");
    await createPyramidTask.ConfigureAwait(false);

Console.WriteLine("duration {0}", DateTime.Now - start);
Console.WriteLine("is killed? {0}", image.IsKilled());
Console.WriteLine("exception: {0}", vipsException?.Message);


Directory.Delete(savePath, true);

Sample image is attached: sample_640× This gets the following output in the console:

killflag set
duration 00:00:11.4808162
is killed? True

So it says it was killed, but instead of terminating after abount 1 second, it more than 10 times as long. And looking in the output folder, the whole image pyramid was actually generated.

Does SetKill() not work on DzSave?

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

kleisaukecommented, Oct 1, 2022
jcupittcommented, Sep 21, 2022

Oh, good idea. The kill flag is checked in the thing that loops down the image, but of course that’s only checked once per line of tiles.

It could maybe go into strip_work() – that might be even quicker. I’ll add this to 8.13. Thanks!

Read more comments on GitHub >

github_iconTop Results From Across the Web

get percentage of progress in dzsave #31 - kleisauke/net-vips
Question: get percentage of progress in dzsave #31 ... This code example now runs without any problems: ... SetKill() and image.
Read more >
libvips and padding when doing image pyramids
Because my image is not square, some padding is necessary when the 256x256 tiles are created. Padding however is different between vips and ......
Read more >
Class Image
If image has been killed (see SetKill(Boolean)), set an error message, clear the kill flag and return true. Otherwise return false.
Read more >
vips: unknown action "dzsave"
I installed it on my windows 10 VM and it worked. I don't see a mention of prereqs as I am downloading the...
Read more >
Image pyramids
libvips includes vips_dzsave() , an operation that can build image pyramids compatible with DeepZoom, Zoomify and Google Maps image viewers.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Post

No results found

github_iconTop Related Hashnode Post

No results found