2

注意:我不打算修改 EXIF 数据!

我正在尝试根据其 EXIF 数据重新定位图像。如果 Orientation 值为3、6 或 8,我会相应地旋转它。

我现在遇到的问题是rotate(),正如文档所说,在我取回没有格式的图像之后。

im.format ⇒ 字符串或无

源文件的文件格式。对于由库本身创建的图像(通过工厂函数,或通过在现有图像上运行方法),此属性设置为 None。

因此,我不能调用_getexif()返回的图像rotate(),因为它不是返回类的成员。如何以编程方式验证轮换是否正确?

编辑:我确实注意到'exif'图像的.info字典中有一个键,但它是一个字节字符串,所以我不知道如何处理它。

4

1 回答 1

0

For 90-degree (clockwise and anti-clockwise) rotations you can verify the width and height values have switched. Obviously this won't help for square images (unlikely for photos).

For 180-degree rotations, verify the width and height haven't changed. Further, you could take some measure of some top rows and bottom rows. For example, convert to greyscale and count the darkness (or keep as colour and count the blueness). Allowing for some variation, the darker side should now be on the other side. You could also measure some left and right rows. Similarly this could be applied for 90-degree rotations.

于 2014-05-11T21:19:28.180 回答