python读取raw图片文件_【IT专家】使用Python读取CR2(原始佳能图像)头。

本文由我司收集整编,推荐下载,如有疑问,请与我司联系

使用

Python

读取

CR2(

原始佳能图像

)

头。

2010/09/12 6673

I’m

trying to extract the date/time when a picture was taken from

the CR2 (Canon format for raw pictures).

我试着从

CR2(

原始图片的

Canon

格式

)

中提取照片的日期

/

时间。

I

know

the CR2 specification,

and

I know

I can

use

Python struct

module

to

extract

pieces from a binary buffer.

我知道

CR2

规范,我知道我可以使用

Python

struct

模块从二进制缓冲区中提取片

段。

Briefly, the specification says that in Tag 0x0132 / 306 I can find an string of length 20

- the date and time.

简单地说,该规范说明在标签

0x0132 /

306

中,我可以找到一个长度为

20

的字符

——

日期和时间。

I tried to get that tag by using:

我试着用

:

struct.unpack_from(20*’s’,

buffer, 0x0132) but I get

但我得到

(‘

\

x00’,

\

x00’,

“‘“,

\x88, ...[and more crap]) Any ideas?

什么好主意吗

?

Edit

编辑

Many thanks for the thorough effort! The answers are phenomenal and I learned a

lot

about handling binary data.

非常感谢您的全面努力

!

答案是惊人的,我学到了很多关于处理二进制数据的知

识。

7

Have you taken into account the header which should (according to the spec)

precede