feat: extend bimg with support for autorotate#181
Conversation
|
Ref #180 |
|
What's wrong with |
|
It's the negation of what I want? And the rotate call requires an angle? |
|
By default, it reads the EXIF data and autorotates the picture. At least, it should do that. |
|
I haven't tested this lib stand-alone, but calling How do I invoke this library's auto-rotate via imaginary to have it only auto-rotate? |
|
Does https://github.com/h2non/imaginary/blob/a1bef74cc15b78a08085a0859c51c9372a0ee593/README.md#params |
|
Some resources for the tests cases: |
|
I just spent 14 hours straight (minus lunch) implementing this feature in the browser with FileReader and ArrayBuffer and Canvas, so I'm pretty into the different rotation modes right now ;) All the code you find online when googling is wrong. |
|
All cases handled: https://codepen.io/haf/pen/OjEBao |
|
@haf the sole fact that https://github.com/h2non/bimg/blob/master/resize.go#L290-L296 I'm onto some test cases. |
|
Thanks for the help, @greut. I can't invest time on this right now, but feel free to send a PR with the required fixes, if needed. There might be something wrong in the implementation. |
|
After seeing this for a bit, I think it would be more convenient relying on |
|
Apparently, |
|
Regarding the refactoring using int
-vips_init_image (void *buf, size_t len, int imageType, VipsImage **out) {
+vips_init_image (void *buf, size_t len, int imageType, int autorotate, VipsImage **out) {
int code = 1;
if (imageType == JPEG) {
- code = vips_jpegload_buffer(buf, len, out, "access", VIPS_ACCESS_RANDOM, NULL);
+ code = vips_jpegload_buffer(buf, len, out,
+ "access", VIPS_ACCESS_RANDOM,
+ "autorotate", with_interlace(autorotate),
+ NULL
+ );But libvips doesn't handle all the EXIF cases 😭, so it's not usable as is. |
|
Right, dammit! |
|
Just convert my four lines of code + sin ± check into a transformation matrix? http://www.vips.ecs.soton.ac.uk/supported/8.3/doc/html/libvips/libvips-resample.html |
|
Can you check now that the default |
|
Have you changed libvips to support all cases? |
|
Can you give me a sample command line to run to test it, please? |
|
@haf bimg != libvips, afaik there are no command-line tools with bimg. |
http://www.vips.ecs.soton.ac.uk/supported/7.42/doc/html/libvips/libvips-conversion.html#vips-autorot