Image.SetKill(true) does not work on DzSave
See original GitHub issueI am having trouble aborting a DzSave call.
Sample Code:
using NetVips;
Console.WriteLine("Starting");
// setup parameters
var testImage = @"sample_640×426.tif";
var savePath = "output";
var saveName = savePath + "/" + "testPyramid";
if (!Directory.Exists(savePath))
Directory.CreateDirectory(savePath);
// open image
using var image = Image.NewFromFile(testImage);
// start creation of pyramid in background task
VipsException? vipsException = null;
var createPyramidTask = Task.Run(() =>
{
{
try
{
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))
Thread.Sleep(10);
image.SetKill(true);
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);
Console.ReadKey();
Directory.Delete(savePath, true);
Sample image is attached: sample_640×426.zip This gets the following output in the console:
Starting
killflag set
duration 00:00:11.4808162
is killed? True
exception:
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:
- Created a year ago
- Comments:5 (4 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Fixed upstream via commit https://github.com/libvips/libvips/commit/fa4b80b74b1c0612a7dac9493aaee491509351a5.
NetVips.Native v8.13.2 is now available.
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!