-
-
Notifications
You must be signed in to change notification settings - Fork 32
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
Gravity function throwing exceptions on specific images #169
Comments
Hi, when I get "out of order read" error message with Netvips, it usually means that the image was opened with sequential read method. Netvips does streaming and caching for most operations to preserve memory and sequential read can do a single pass only. It is possible that your gravity functions require more than one pass over the image data or require reads at random positions. Try opening your image with random access. Snippet below is how I open images.
|
@CanadianHusky Thanks a lot for the response! I have tried what you suggested and I get no faults now (except with image 4, zz12AVIF.avif above). But my concern is that I have read comments from @kleisauke like this one:
and speed is fairly important in my case, I have large source images to deal with, and the shrink on load functionality is a lifesaver. I guess I could try Thumbnail, then if it fails, delete the zero bytes image it generates, then try ThumbnailImage. Slow is better than none at all. |
Hi @Transigent,
using var thumb = Image.Thumbnail("x.jpg", 640);
using var gravity = thumb.Gravity(Enums.CompassDirection.Centre, 640, 640,
extend: Enums.Extend.Background, background: new[] { 128.0 });
gravity.Jpegsave("gravity_x.jpg", strip: true, q: 80); You could also use using var thumb = Image.Thumbnail("x.jpg", 640);
using var memory = thumb.CopyMemory();
memory.Jpegsave("thumb_x.jpg", strip: true, q: 80);
using var gravity = memory.Gravity(Enums.CompassDirection.Centre, 640, 640,
extend: Enums.Extend.Background, background: new[] { 128.0 });
gravity.Jpegsave("gravity_x.jpg", strip: true, q: 80); Finally, you could also open the image in random access mode and use There's a handy chapter in the docs explaining how libvips opens files, which gives some more background.
This AVIF image looks like 10-bit, which is unsupported by the pre-built libvips binaries provided by NetVips. $ heif-info -d zz12AVIF.avif | grep bit
| | | bits_per_channel: 10
| | | high_bitdepth: 1
| | | twelve_bit: 0 See the
|
Thank you so much @kleisauke, I really appreciate the great suggestions and the support in general. I will give these things a try ASAP. |
@Transigent Were you able to make any progress with this? |
Thanks for the support, I used the CopyMemory option and it worked great. Once again thanks for the great library. I will close this issue. |
Hi, first of all thanks for the superb NetVips library.
I have been doing some format tests for various images. For some images I am having an odd problem when I call WriteToFile after the Gravity function. Most JPG and various other formats (eg. WEBP, GIF, BMP, SVG, PDF, AVIF, TGA, JP2) all seem to work fine. In the code below, for each image:
I have supplied 4 sample images that are giving me trouble. For the first 3 (0016524.tiff, abcd.jfif, dddJFIF.jfif) I successfully load and WriteToFile the thumbnail but I get an exception on the line where I WriteToFile the Gravity processed image :
0016524.tiff
abcd.jfif
dddJFIF.jfif
For the 4th file zz12AVIF.avif it does not get past the thumbnail stage with the error:
I am using the latest vips-dev ALL 8.12.2 version along with NetVips 2.1.0
I have tried running the command line tool vipsthumbnail.exe to create thumbs and they work except for the 4th file. I successfully use vips.exe to generate a file with plain Gravity applied, for the first 3 files, using
vips gravity abcd.jfif abcd.jpg centre 640 640 --background "128,128,128"
which works for all except the 4th file. Its like I am doing something wrong in the vb.net code.
Can you make any suggestions as to what I am doing wrong? Thanks for any advice.
My code is as follows:
System - Windows 10, Version 10.0.19043 Build 19043
Project - VB.NET Framework 4.6.1, x64
Nuget Packages - NetVips 2.1.0, NetVips.Extensions 2.1.0, System.Buffers 4.5.1, System. Memory 4.5.5, System.Numerics.Vectors 4.5.0, System.Runtime.CompilerServices.Unsafe 6.0.0
libvips - vips-dev-w64-all-8.12.2.zip
TestFiles.zip
The text was updated successfully, but these errors were encountered: