Wouldn't it make more sense if `image::open()` automatically applied the orientation by default?
Resizing images in Rust, now with EXIF orientation support
31–35 of 35 posts
Re: Resizing images in Rust, now with EXIF orientation support
#32I ran into the same issue when working with image processing in Go using libvips. By default, libvips ignores EXIF orientation too, so I had to explicitly read and apply the orientation tag before doing any resize or crop. Otherwise users ended up with upside-down processed images from photos. Glad to see this is getting better in Rust.
VipsImage *image = vips_image_new_from_file("something.jpg", "autorotate", TRUE, NULL);
and it'll flip it upright for you and remove any EXIF orientation tag. It isn't the default since it has (obviously) a large memory and cpu cost.
For simple resize and crop it's much better to use the exif tag to adjust the resize and crop parameters (the vipsthumbnail command does this).
Re: Resizing images in Rust, now with EXIF orientation support
#33I ran into the same issue when working with image processing in Go using libvips. By default, libvips ignores EXIF orientation too, so I had to explicitly read and apply the orientation tag before doing any resize or crop. Otherwise users ended up with upside-down processed images from photos. Glad to see this is getting better in Rust.
Hello, libvips author here, the JPEG loader has a flag to do this for you. You can write: VipsImage *image = vips_image_new_from_file("something.jpg", "autorotate", TRUE, NULL); and it'll flip it upright for you and remove any EXIF orientation tag. It isn't the default since it has (obviously) a large memory and cpu cost. For simple resize and crop it's much better to use the exif tag to adjust the resize and crop pa…
In my Go project I’m using the Golang library github.com/davidbyttow/govips/v2.
Images are loaded via `vips.NewImageFromFile()`, which internally calls `vips_image_new_from_file()`. However, `NewImageFromFile()` doesn't support any flags or options beyond the image path, so for JPEGs I manually call `AutoRotate()` before resizing, which wraps `vips_autorot()` — and that works well.
Thanks again!
Re: Resizing images in Rust, now with EXIF orientation support
#34Earlier quoted context omitted.
Hello, libvips author here, the JPEG loader has a flag to do this for you. You can write: VipsImage *image = vips_image_new_from_file("something.jpg", "autorotate", TRUE, NULL); and it'll flip it upright for you and remove any EXIF orientation tag. It isn't the default since it has (obviously) a large memory and cpu cost. For simple resize and crop it's much better to use the exif tag to adjust the resize and crop pa…
Thanks so much for the clarification and for the great work on libvips! In my Go project I’m using the Golang library github.com/davidbyttow/govips/v2. Images are loaded via `vips.NewImageFromFile()`, which internally calls `vips_image_new_from_file()`. However, `NewImageFromFile()` doesn't support any flags or options beyond the image path, so for JPEGs I manually call `AutoRotate()` before resizing, which wraps `vi…
`govips` was a pretty early binding and wasn't really done the libvips way. It doesn't expose all the operations or options, it's mostly done by hand, and there are a number of leaks and misfeatures.
It's been replaced by `vipsgen`:
https://github.com/cshum/vipsgen
Which is an automatically generated 100% binding. It should have the complete API, it should be very stable and leak-free, and it should be simple to maintain.
`autorot` is pretty expensive. You'll see much better performance if you flip x and y in your crop instead.
Re: Resizing images in Rust, now with EXIF orientation support
#35Earlier quoted context omitted.
Thanks so much for the clarification and for the great work on libvips! In my Go project I’m using the Golang library github.com/davidbyttow/govips/v2. Images are loaded via `vips.NewImageFromFile()`, which internally calls `vips_image_new_from_file()`. However, `NewImageFromFile()` doesn't support any flags or options beyond the image path, so for JPEGs I manually call `AutoRotate()` before resizing, which wraps `vi…
Ah no problem! I'm glad it's useful. `govips` was a pretty early binding and wasn't really done the libvips way. It doesn't expose all the operations or options, it's mostly done by hand, and there are a number of leaks and misfeatures. It's been replaced by `vipsgen`: https://github.com/cshum/vipsgen Which is an automatically generated 100% binding. It should have the complete API, it should be very stable and leak-…
I wasn’t aware of `vipsgen`, but it looks great — full coverage and auto-generated bindings are exactly what I’ll be missing in `govips` if the project grows (I hope it will). I’ll definitely give it a try and see how it works.
Also, great tip on avoiding `autorot` by flipping crop coordinates — I hadn’t thought of that! Thanks again for your help!