DateTaken attribue [英] The DateTaken attribue

查看:115
本文介绍了DateTaken attribue的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好b $ b

我正在寻找一种以编程方式访问.JPG照片所具有的DateTaken属性的方法。

任何人都可以在c ++中给我一个例子?



谢谢

解决方案

在澄清之前,这不是一个讨论问题:JPEG。谢谢。



在这种情况下,你需要解析EXIF:

http://en.wikipedia.org/wiki/EXIF [ ^ ]。



例如,请参阅此库: http://www.exiv2.org/ [ ^ ]。



-SA


我在阅读this [ ^ ]优秀文章。



因此,这些部分实际上为您提供了Date Taken属性,正如Sergey正确指出的那样,该属性来自EXIF,只有基于JPEG的文件才有。



 EXIFINFO exifinfo; 
memset(& exifinfo,0,sizeof(EXIFINFO));
Cexif exif(& exifinfo);
bool decode_success = false;
decode_success = exif.DecodeExif(hFile);
fclose(hFile);

if(decode_success&& exifinfo.IsExif){
CString sDatetime = exifinfo.DateTime;
if(sDatetime.GetLength()== 19
&& _T()!= sDatetime.Left(4)
&& _T(0000)! = sDatetime.Left(4)
)//确保存在完整的日期和时间YYYY:MM:DD HH:MM :: SS
{
int d_yyyy = StrToInt( sDatetime.Left(4));
int d_mm = StrToInt(sDatetime.Mid(4 + 1,2));
int d_dd = StrToInt(sDatetime.Mid(4 + 1 + 2 + 1,2));
int t_hh = StrToInt(sDatetime.Mid(4 + 1 + 2 + 1 + 2 + 1,2));
int t_mm = StrToInt(sDatetime.Mid(4 + 1 + 2 + 1 + 2 + 1 + 2 + 1,2));
int t_ss = StrToInt(sDatetime.Mid(4 + 1 + 2 + 1 + 2 + 1 + 2 + 1 + 2 + 1,2));
//这里你有DateTaken值..,


我写了一篇文章,其中包含了更改Date Taken属性所需的源代码。

日期&时间批量转换器的照片和其他文件 [ ^ ]



谢尔盖·亚历山德罗维奇绝对正确,它只能用于JPEG文件。

Hi
I am looking for a way to programatically access the DateTaken attribute a .JPG photo has.
Can anyone give me an example in c++?

Thanks

解决方案

It wasn't a matter of discussion before you clarified: JPEG. Thank you.

In this case, you need to parse EXIF:
http://en.wikipedia.org/wiki/EXIF[^].

See, for example, this library: http://www.exiv2.org/[^].

—SA


I found the solution after reading this [^]excellent article.

So that parts actually give you the "Date Taken" property, which as Sergey rightly stated, is taken from the EXIF that only JPEG based files have.

EXIFINFO exifinfo;
memset(&exifinfo,0,sizeof(EXIFINFO));
Cexif exif(&exifinfo);
bool decode_success = false;
decode_success = exif.DecodeExif(hFile);
fclose(hFile);

if (decode_success && exifinfo.IsExif) {
	CString sDatetime = exifinfo.DateTime;
	if (sDatetime.GetLength() == 19 
		&& _T("    ") != sDatetime.Left(4)
		&& _T("0000") != sDatetime.Left(4)
	) // make sure that full date and time is present "YYYY:MM:DD HH:MM::SS"
	{
		int d_yyyy = StrToInt (sDatetime.Left(4));
		int d_mm   = StrToInt (sDatetime.Mid(4+1,     2));
		int d_dd   = StrToInt (sDatetime.Mid(4+1+2+1, 2));
		int t_hh   = StrToInt (sDatetime.Mid(4+1+2+1+2+1, 2));
		int t_mm   = StrToInt (sDatetime.Mid(4+1+2+1+2+1+2+1, 2));
		int t_ss   = StrToInt (sDatetime.Mid(4+1+2+1+2+1+2+1+2+1, 2));
// here you have the DateTaken value..,


I wrote an article with the required source code to change the Date Taken attribute.
Date & time batch changer for photos and other files[^]

Sergey Alexandrovich is absolutely right that it will only work on JPEG files.


这篇关于DateTaken attribue的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆