获取图片的metaData
获取图片的metaData

获取简易的metaData较为容易,以下是测试图:

以下是本人提供的源码:
UIImage+MetaData.h
//
// UIImage+MetaData.h
// PictureInfo
//
// Created by YouXianMing on 14-8-27.
// Copyright (c) 2014年 YouXianMing. All rights reserved.
// #import <UIKit/UIKit.h> @interface UIImage (MetaData) - (NSDictionary *)JPEGmetaData;
- (NSDictionary *)PNGmetaData; @end
UIImage+MetaData.h
//
// UIImage+MetaData.m
// PictureInfo
//
// Created by YouXianMing on 14-8-27.
// Copyright (c) 2014年 YouXianMing. All rights reserved.
// #import "UIImage+MetaData.h"
#import <AssetsLibrary/AssetsLibrary.h>
#import <ImageIO/ImageIO.h> @implementation UIImage (MetaData) - (NSDictionary *)JPEGmetaData
{
if (self == nil)
{
return nil;
} // 转换成jpegData,信息要多一些
NSData *jpegData = UIImageJPEGRepresentation(self, 1.0);
CGImageSourceRef source = CGImageSourceCreateWithData((__bridge CFDataRef)jpegData, NULL);
CFDictionaryRef imageMetaData = CGImageSourceCopyPropertiesAtIndex(source, , NULL);
CFRelease(source); NSDictionary *metaDataInfo = CFBridgingRelease(imageMetaData);
return metaDataInfo;
} - (NSDictionary *)PNGmetaData
{
if (self == nil)
{
return nil;
} NSData *pngData = UIImagePNGRepresentation(self);
CGImageSourceRef source = CGImageSourceCreateWithData((__bridge CFDataRef)pngData , NULL);
CFDictionaryRef imageMetaData = CGImageSourceCopyPropertiesAtIndex(source, , NULL);
CFRelease(source); NSDictionary *metaDataInfo = CFBridgingRelease(imageMetaData);
return metaDataInfo;
} @end
使用情况:
//
// AppDelegate.m
// GetPictureInfo
//
// Copyright (c) 2014年 Y.X. All rights reserved.
// #import "AppDelegate.h"
#import "UIImage+MetaData.h" @implementation AppDelegate - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch. NSLog(@"%@", [[UIImage imageNamed:@"IMG_0151.JPG"] JPEGmetaData]); self.window.backgroundColor = [UIColor whiteColor];
[self.window makeKeyAndVisible];
return YES;
} @end
以下是打印信息:
{
ColorModel = RGB;
Depth = 8;
Orientation = 1;
PixelHeight = 1936;
PixelWidth = 2592;
"{Exif}" = {
ColorSpace = 1;
PixelXDimension = 2592;
PixelYDimension = 1936;
};
"{JFIF}" = {
DensityUnit = 0;
JFIFVersion = (
1,
1
);
XDensity = 1;
YDensity = 1;
};
"{TIFF}" = {
Orientation = 1;
};
}
几个需要注意的地方:
1. 需要引入两个库

2. 一些需要注意的细节

你以为结束了么?没有呢,你还没取到图片的经纬度信息,对吧,一下给你提供资料自己去尝试:)
http://stackoverflow.com/questions/9766394/get-exif-data-from-uiimage-uiimagepickercontroller
|
Interesting question! I came up with the following solution working Import Then include the needed classes inside your .h-file:
And put this inside your
One thing I noticed is, that iOS will ask the user to allow location services – if he denies, you won't be abled to get the image data … EDIT Added code to save the image including its meta data. It's a quick approach, so maybe there is a better way, but it works! |
|||||||||||||||||||||
|


|
I had found solution and got answer from here From here We can get GPS info as well.. Amazing and thanks all for helping me to solve this problem. UPDATE This is another function that I had created myself, also return Exif
and We will retrieve that data like this
For all of this you should have to Import |
|||||||||||||||||||||
|
|
These answers all seem extremely complex. If the image has been saved
If you want to save that image from camera roll to another location (say in Sandbox/Documents) simply do:
|
|||||||||
|
|
You need ALAssetsLibrary to actually retrieve the EXIF info from an |
|||
|
I have tried to insert GPS coordinates into image metadata picked by iPad Camera as it was suggested by Mehul. P.S.
... By supposing that you have already initializied somewhere locationManager in your code, like this:
and by importing CoreLocation/CoreLocation.h and ImageIO/ImageIO.h headers with associated frameworks. |
获取图片的metaData的更多相关文章
- jsoup获取图片示例
import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.io.Inp ...
- 【记录】JS 获取图片原始尺寸-防止图片溢出
示例代码: <div id="div_content"> <img src="http://static.cnblogs.com/images/logo ...
- C#获取图片的后缀名
最近在学习过程中遇到一个问题,就是如何获取图片的格式,对于一张知道全路径的照片,如果其路径包含后缀名的话,要取得后缀名,只需要一行代码即可: var ext = System.IO.Path.GetE ...
- js和jquery如何获取图片真实的宽度和高度
按照插入的图片的尺寸来判断图片是横图还是竖图.然后判断过后给予不同的展示方式,下面为大家介绍下js和jquery如何获取图片真实的宽度和高度 1.什么时候需要获取图片真实的宽度和高度 在做pc网页 ...
- 限制Xamarin获取图片的大小
限制Xamarin获取图片的大小在App开发中,经常会使用网络图片.因为这样不仅可以减少App的大小,还可以动态更新图片.但是手机使用网络环境千差万别.当网络环境不是理想的情况下,加载网络图片就是一个 ...
- js和jquery获取图片真实的宽度和高度
1.什么时候需要获取图片真实的宽度和高度 在做pc网页的时候,有时候会考虑按照插入的图片的尺寸来判断图片是横图还是竖图.然后判断过后给予不同的展示方式! 另外一种就是在手机页面上,在新闻页插入的图片往 ...
- java获取图片原始尺寸
java获取图片原始尺寸 URL url = null; InputStream is = null; BufferedImage img = null; try { url = new URL(pi ...
- Js获取图片原始宽高
如果我们页面看到的图片都是缩略图,那就需要做个图片点击放大效果,那么怎样获取图片的原始宽高呢?方法如下: //获取图片原始宽度 function getNaturalWidthAndHeight(im ...
- 获取图片工具类:BitmapUtil
package com.example.administrator.filemanager.utils;import android.content.Context;import android.gr ...
随机推荐
- android学习-ndk-build(androidstudio编译cocos2d-x库的cpp为so文件的解释)
本文不作为ndk初学使用,只是对cpp等c++文件编译成so文件的过程中,参数含义,及ndk配置的解释.使用的技术比较旧. androidStudio使用gradle调用ndk-build工具编译c+ ...
- springboot-13-junitTest
junitTest, 提喜欢用的一个方法, 在测试代码时非常好用 1, 添加maven依赖 <!-- 加入spring-test依赖 --> <dependency> < ...
- 说说java
先说什么是java java是一种面向对象语言,真正的面向对象,任何函数和变量都以类(class)封装起来 至于什么是对象什么是类,我就不废话了 关于这两个概念的解释任何一本面向对象语言的教材里面都有 ...
- Linux下编译ffmpeg并用GDB调试
1.在Ubuntu界面上调处命令行界面,最方便的方式是使用快捷键Ctrl+Alt+T. 2.安装SDL SDL是一个开源的多媒体开发库,可以设置图像和视频的绘制等操作.如果不安装SDL,FFMPEG将 ...
- [BZOJ 5072]小A的树
Description 题库链接 给你 \(n\) 个节点的一棵树,点分黑白. \(q\) 组询问,每次询问类似于"是否存在树中 \(x\) 个点的连通块恰有 \(y\) 个黑点" ...
- springboot jpa 多条件查询(多表)
前几天写的,贴上来. 实体类. package com.syl.demo.daomain; import lombok.Data; import javax.persistence.*; /** * ...
- [转]VS2013中使用Git建立源代码管理
本文转自:https://blog.csdn.net/bodybo/article/details/38976549 第一次在VS2013中使用Git,也是第一次使用Git,各种不熟悉.百度各种使用经 ...
- mysql中的坑
1,MySQL建表中double类型不能限制数据长度! 2,……
- SpringCloud Eureka(注册中心集群)
多个注册中心,其实用不同的配置对应 不同的端口号注册就行了. 注册中心自己也是个服务,看看之前的单个注册中心是怎么样的呢? server: port: 8888 # 服务端口eureka: insta ...
- JDBC程序优化--提取配置信息放到属性文件中
JDBC程序优化--提取配置信息放到属性文件中 此处仅仅优化JDBC连接部分,代码如下: public class ConnectionFactory { private static String ...

