ext/rfreeimage/rfi_main.c in rfreeimage-0.1.3 vs ext/rfreeimage/rfi_main.c in rfreeimage-0.1.5

- old
+ new

@@ -99,11 +99,13 @@ free(filename); rb_raise(rb_eIOError, "Invalid image file"); } if (ping) flags |= FIF_LOAD_NOPIXELS; - if (in_fif == FIF_JPEG) flags |= JPEG_EXIFROTATE; + // use JPEG_ACCURATE to keep sync with opencv + if (in_fif == FIF_JPEG) + flags |= JPEG_EXIFROTATE | JPEG_ACCURATE; orig = FreeImage_Load(in_fif, filename, flags); free(filename); if (!orig) rb_raise(rb_eIOError, "Fail to load image file"); if (ping) { @@ -125,10 +127,11 @@ static void rd_image_blob(VALUE clazz, VALUE blob, struct native_image *img, unsigned int bpp, BOOL ping) { FIBITMAP *h = NULL, *orig = NULL; FIMEMORY *fmh; + int flags = 0; FREE_IMAGE_FORMAT in_fif; Check_Type(blob, T_STRING); fmh = FreeImage_OpenMemory((BYTE*)RSTRING_PTR(blob), RSTRING_LEN(blob)); @@ -136,10 +139,13 @@ if (in_fif == FIF_UNKNOWN) { FreeImage_CloseMemory(fmh); rb_raise(rb_eIOError, "Invalid image blob"); } - orig = FreeImage_LoadFromMemory(in_fif, fmh, ping ? FIF_LOAD_NOPIXELS : 0 ); + if (ping) flags |= FIF_LOAD_NOPIXELS; + if (in_fif == FIF_JPEG) + flags |= JPEG_EXIFROTATE | JPEG_ACCURATE; + orig = FreeImage_LoadFromMemory(in_fif, fmh, flags); FreeImage_CloseMemory(fmh); if (!orig) rb_raise(rb_eIOError, "Fail to load image from memory"); if (ping) {