libexif库介绍

      libexif是一个用于解析、编辑和保存EXIF数据的库。它支持EXIF 2.1标准(以及2.2中的大多数)中描述的所有EXIF标签。它是用纯C语言编写的,不需要任何额外的库。源码地址:https://github.com/libexif/libexif ,最新发布版本为0.6.24,它的license为LGPL-2.1。

      EXIF全称为Exchangeable Image File format,可交换图像文件格式是专门为数码相机的照片设定的文件格式,可以记录数码照片的属性信息和拍摄数据EXIF可以附加于JPEG、TIFF、RIFF等文件之中,为其增加有关数码相机拍摄信息的内容和索引图或图像处理软件的版本信息。EXIF信息是可以被任意编辑的,因此只有参考的功能。
      EXIF信息以0xFFE1作为开头标记,后两个字节表示EXIF信息的长度。所以EXIF信息最大为64kB,而内部采用TIFF格式。

      libexif在Windows和Linux上编译过程:

      从https://github.com/libexif/libexif.git clone源码,然后切换到tag v0.6.24,执行:git checkout v0.6.24

      1.Linux上编译:

      (1).需要先安装依赖,执行如下命令:

sudo apt install autoconf autopoint libtool

      (2).编译源码,依次执行如下命令:

autoreconf -i
./configure --prefix=${PWD}/install --disable-docs
make
make install

      编译完成后在install目录下,会生成include、lib、share三个目录。

      2.Windows上编译:

      (1).新建libexif工程,参考Linux下生成的libexif.a中的文件,将相关文件添加到工程中;

      (2).将Linux下生成的config.h文件做调整并添加到libexif工程中,调整后的config.h内容如下:

/* config.h.  Generated from config.h.in by configure.  */
/* config.h.in.  Generated from configure.ac by autoheader.  *//* Define to 1 if translation of program messages to the user's nativelanguage is requested. */
/* #undef ENABLE_NLS */#define GETTEXT_PACKAGE "libexif-12"#if defined(_MSC_VER)#  pragma warning(push)#  pragma warning(disable: 4127) // warning C4127: Conditional expression is constant#include <BaseTsd.h>typedef SSIZE_T ssize_t;
#endif/* Define to 1 if you have the Mac OS X function CFLocaleCopyCurrent in theCoreFoundation framework. */
/* #undef HAVE_CFLOCALECOPYCURRENT *//* Define to 1 if you have the Mac OS X function CFPreferencesCopyAppValue inthe CoreFoundation framework. */
/* #undef HAVE_CFPREFERENCESCOPYAPPVALUE *//* Define if the GNU dcgettext() function is already present or preinstalled.*/
/* #undef HAVE_DCGETTEXT *//* Define to 1 if you have the <dlfcn.h> header file. */
/* #undef HAVE_DLFCN_H *//* Define if the GNU gettext() function is already present or preinstalled. */
/* #undef HAVE_GETTEXT *//* Define if you have the iconv() function and it works. */
/* #undef HAVE_ICONV *//* Define to 1 if you have the <inttypes.h> header file. */
#define HAVE_INTTYPES_H 1/* Define to 1 if you have the `localtime_r' function. */
/* #undef HAVE_LOCALTIME_R *//* Define to 1 if you have localtime_s() */
#define HAVE_LOCALTIME_S 1/* Define to 1 if you have the <stdint.h> header file. */
#define HAVE_STDINT_H 1/* Define to 1 if you have the <stdio.h> header file. */
#define HAVE_STDIO_H 1/* Define to 1 if you have the <stdlib.h> header file. */
#define HAVE_STDLIB_H 1/* Define to 1 if you have the <strings.h> header file. */
/* #undef HAVE_STRINGS_H *//* Define to 1 if you have the <string.h> header file. */
#define HAVE_STRING_H 1/* Define to 1 if you have the <sys/stat.h> header file. */
#define HAVE_SYS_STAT_H 1/* Define to 1 if you have the <sys/types.h> header file. */
#define HAVE_SYS_TYPES_H 1/* Define to 1 if you have the <unistd.h> header file. */
/* #undef HAVE_UNISTD_H *//* Define as const if the declaration of iconv() needs const. */
/* #undef ICONV_CONST *//* Define to the sub-directory where libtool stores uninstalled libraries. */
//#define LT_OBJDIR ".libs/"/* Name of package */
#define PACKAGE "libexif"/* Define to the address where bug reports for this package should be sent. */
#define PACKAGE_BUGREPORT "libexif-devel@lists.sourceforge.net"/* Define to the full name of this package. */
#define PACKAGE_NAME "EXIF library"/* Define to the full name and version of this package. */
#define PACKAGE_STRING "EXIF library 0.6.24"/* Define to the one symbol short name of this package. */
#define PACKAGE_TARNAME "libexif"/* Define to the home page for this package. */
#define PACKAGE_URL "https://libexif.github.io/"/* Define to the version of this package. */
#define PACKAGE_VERSION "0.6.24"/* Define to 1 if all of the C90 standard headers exist (not just the onesrequired in a freestanding environment). This macro is provided forbackward compatibility; new code need not use it. */
#define STDC_HEADERS 1/* Version number of package */
#define VERSION "0.6.24"/* Number of bits in a file offset, on hosts where this is settable. */
/* #undef _FILE_OFFSET_BITS *//* Define for large files, on AIX-style hosts. */
/* #undef _LARGE_FILES *//* Define to `__inline__' or `__inline' if that's what the C compilercalls it, or to nothing if 'inline' is not supported under any name.  */
#ifndef __cplusplus
/* #undef inline */
#endif

      (3).将Linux上生成的_stdint.h文件也添加到此工程中;

      (4).编译工程生成libexif.lib静态库。

      对带有exif信息的jpg图像生成缩略图的测试代码如下:

int test_libexif_thumbnail()
{// reference: https://github.com/libexif/libexif/blob/master/contrib/examples/thumbnail.c// Create an ExifLoader object to manage the EXIF loading processExifLoader* l = exif_loader_new();if (!l) {std::cerr << "Error: fail to exif_loader_new\n";return -1;}#ifdef _MSC_VERconstexpr char* jpg_name{ "../../../test_images/exif.jpg" };
#elseconstexpr char* jpg_name{ "test_images/exif.jpg" };
#endif// Load the EXIF data from the image fileexif_loader_write_file(l, jpg_name);// Get a pointer to the EXIF dataExifData* ed = exif_loader_get_data(l);if (!ed) {std::cerr << "Error: fail to exif_loader_get_data\n";return -1;}// The loader is no longer needed--free itexif_loader_unref(l);// Make sure the image had a thumbnail before trying to write itif (ed->data && ed->size) {std::cout << "exif data size: " << ed->size << "\n";char thumb_name[1024];snprintf(thumb_name, sizeof(thumb_name), "%s_thumb.jpg", jpg_name);FILE* thumb = fopen(thumb_name, "wb");if (!thumb) {std::cerr << "Error: fail to fopen: " << thumb_name << "\n";return -1;}// Write the thumbnail image to the filefwrite(ed->data, 1, ed->size, thumb);fclose(thumb);}exif_data_unref(ed);return 0;
}

      Windows上和Linux上的执行结果如下图所示:

      GitHub:https://github.com/fengbingchun/OpenCV_Test

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.hqwc.cn/news/327741.html

如若内容造成侵权/违法违规/事实不符,请联系编程知识网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

【v8漏洞利用模板】starCTF2019 -- OOB

文章目录 前言参考题目环境配置漏洞分析 前言 一道入门级别的 v8 题目&#xff0c;不涉及太多的 v8 知识&#xff0c;很适合入门&#xff0c;对于这个题目&#xff0c;网上已经有很多分析文章&#xff0c;笔者不再为大家制造垃圾&#xff0c;仅仅记录一个模板&#xff0c;方便…

TYPE-C接口取电芯片介绍和应用场景

随着科技的发展&#xff0c;USB PDTYPE-C已经成为越来越多设备的充电接口。而在这一领域中&#xff0c;LDR6328Q PD取电芯片作为设备端协议IC芯片&#xff0c;扮演着至关重要的角色。本文将详细介绍LDR6328Q PD取电芯片的工作原理、应用场景以及选型要点。 一、工作原理 LDR63…

2024年天津体育学院专升本专业考试体育教育专业素质测试说明

天津体育学院2024年高职升本科招生专业考试体育教育专业素质测试说明 一、测试内容 100米跑、立定跳远、原地推铅球 二、考试规则 1.100米跑可穿跑鞋&#xff08;短钉&#xff09;&#xff0c;起跑采用蹲踞式。抢跑个人累计犯规两次&#xff0c;取消本项考试资格&#xff0c…

解决使用localhost或127.0.01模拟CORS失效

解决使用localhost或127.0.01模拟CORS失效 前言问题发现问题解决 前言 CORS (Cross-Origin Resource Sharing) 指的是一种机制&#xff0c;它允许不同源的网页请求访问另一个源服务器上的某些资源。通常情况下&#xff0c;如果 JavaScript 代码在一个源中发起了 AJAX 请求&…

css的一些属性

我们在写项目的时候&#xff0c;会遇到多种多样的样式&#xff0c;大部分都是由css来实现的&#xff0c;css可以让我们的页面更美观&#xff0c;css通常是配合HTML使用&#xff0c;代码较为简单! 下面我就给大家举几个较为常用的一些css属性。 1.CSS中怎样让元素圆角化&#…

spring boot 2升级为spring boot 3中数据库连接池druid的问题

目录 ConfigurationClassPostProcessor ConfigurationClassBeanDefinitionReader MybatisPlusAutoConfiguration ConditionEvaluator OnBeanCondition 总结 近期给了一个任务&#xff0c;要求是对现有的 spring boot 2.x 项目进行升级&#xff0c;由于 spring boot 2.x 版…

数据结构和算法-交换排序中的快速排序(演示过程 算法实现 算法效率 稳定性)

文章目录 总览快速排序&#xff08;超级重要&#xff09;啥是快速排序演示过程算法实现第一次quicksort函数第一次partion函数到第一次quicksort的第一个quicksort到第二次quicksort的第一个quicksort到第二次quicksort的第二个quicksort到第一次quicksort的第二个quicksort到第…

while猜数字实例——C++版

案例描述&#xff1a;系统随机生成一个1到100之间的数字&#xff0c;玩家进行猜测&#xff0c;如果猜错&#xff0c;提示玩家数字过大或过小&#xff0c;如果猜对恭喜玩家胜利并退出游戏。 逻辑框图&#xff1a; #include<bits/stdc.h> using namespace std; int main()…

The Planets: Mercury

靶场环境 整个靶场的环境&#xff0c;我出现了一点点问题&#xff0c;一直找不到主机的IP地址&#xff0c;后来参考了https://www.cnblogs.com/hyphon/p/16354436.html&#xff0c;进行了相关的配置&#xff0c;最后完成靶机环境的搭建&#xff01; 信息收集 # nmap -sn 192…

Linux Debian12系统gnome桌面环境默认提供截屏截图工具gnome-screenshot

一、简介&#xff1a; 在Debian12中系统gnome桌面环境默认提供一个截图捕获工具screenshot,可以自定义区域截图、屏幕截图、窗口截图和录制视频&#xff0c;截图默认保存在“~/图片/截图”路径下。 可以在应用程序中搜索screenshot,如下图&#xff1a; 也可以在桌面右上角找到…

mysql之视图执行计划

一.视图 1.1视图简介 1.2 创建视图 1.3视图的修改 1.4视图的删除 1.5查看视图 二.连接查询案例 三.思维导图 一.视图 1.1视图简介 虚拟表&#xff0c;和普通表一样使用 MySQL中的视图&#xff08;View&#xff09;是一个虚拟表&#xff0c;其内容由查询定义。与实际表不…

DevSecOps 工具:初学者指南

DevSecOps 是开发、安全和运营的融合&#xff0c;标志着软件开发的范式转变&#xff0c;在整个软件开发生命周期 (SDLC)中无缝集成安全性。 这种方法标志着不再将安全视为开发过程中的一个阶段。除了DevSecOps 的核心原则和最佳实践之外&#xff0c;特定工具也是实施和强化安全…

C++学习笔记——类作用域和抽象数据类型

目录 一、C类作用域 类内作用域 类外作用域 二、类作用域案列详细的解释说明 三、抽象数据类型 四、总结 类作用域 抽象数据类型&#xff08;ADT&#xff09; 五、图书馆管理系统 一、C类作用域 在C中&#xff0c;类作用域是指类定义中声明的标识符&#xff08;成员变…

如何使用UUP从windows更新服务器下载windows10原版镜像

UUP是指Windows 10中的一种更新技术&#xff0c;全称为Unified Update Platform。UUP的目标是提供更快、更高效的更新体验&#xff0c;它通过增量更新的方式来更新操作系统&#xff0c;只下载和安装实际变化的部分&#xff0c;而不是整个更新包。这样可以节省带宽和时间&#x…

时间序列预测 — LSTM实现多变量多步负荷预测(Tensorflow):多输入多输出

目录 1 数据处理 1.1 导入库文件 1.2 导入数据集 ​1.3 缺失值分析 2 构造训练数据 3 LSTM模型训练 4 LSTM模型预测 4.1 分量预测 4.2 可视化 1 数据处理 1.1 导入库文件 import time import datetime import pandas as pd import numpy as np import matplotlib.p…

华为面经总结

为了帮助大家更好的应对面试&#xff0c;我整理了往年华为校招面试的题目&#xff0c;供大家参考~ 面经1 技术一面 自我介绍说下项目中的难点volatile和synchronized的区别&#xff0c; 问的比较细大顶堆小顶堆怎么删除根节点CSRF攻击是什么&#xff0c;怎么预防线程通信方式…

C#不会循环响应的Action设计与实现

目录 一、简述二、测试代码三、测试的输出四、核心代码五、其它 一、简述 特点&#xff1a; 不光是能防止直接的死循环调用&#xff1b;还能防止间接的死循环调用&#xff1b;还支持对不同参数判定&#xff0c;不同参数的调用可以不当循环调用&#xff1b; 消息事件系统中必…

leetcode——杨辉三角

https://leetcode.cn/problems/pascals-triangle/ 杨辉三角&#xff1a; 给定一个非负整数 numRows&#xff0c;生成「杨辉三角」的前 numRows 行。 在「杨辉三角」中&#xff0c;每个数是它左上方和右上方的数的和。 核心思想&#xff1a;找出杨辉三角的规律&#xff0c;发…

PromptCast:基于提示学习的时序预测模型!

目前时序预测的SOTA模型大多基于Transformer架构&#xff0c;以数值序列为输入&#xff0c;如下图的上半部分所示&#xff0c;通过多重编码融合历史数据信息&#xff0c;预测未来一定窗口内的序列数值。 受到大语言模型提示工程技术的启发&#xff0c;文章提出了一种时序预测新…

FastDFS实战

目录 目标 版本 环境 官方文档 相关概念 安装FastDFS 启动FastDFS 关闭FastDFS 重启FastDFS 用命令测试上传文件 用命令测试下载文件 用命令测试删除文件 用HTTP的方式访问FastDFS中的文件 用HTTP的方式访问FastDFS中的文件整体流程 目标 在Linux服务器上搭建Fa…