获取图片的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 ...
随机推荐
- PHP在使用正则表达式验证,防注入的时候要注意一下的细节
如下:这是一个防止用户输入的数据中包含SQL的一些关键字的正则表达式 之前一直认为这写的很正确,没多大的问题,而且自己测试也没问题, 因为关键字包含 And,而如果用户输入andy的时候呢,汗,所以还 ...
- 深度剖析Dubbo源码
-----------------学习dubbo源码,能给你带来什么好处?----------- 1.提升SOA的微服务架构设计能力 通过读dubbo源码是一条非常不错的通往SOA架构设计之路,毕 ...
- Spring4.x所有Maven依赖
Spring4.x所有Maven依赖 定义Spring版本号 1 <properties> 2 <org.springframework.version>4.3.7.RELEA ...
- RabbitMQ上手记录–part 4-节点集群(单机多节点)
现在互联网应用动不动就说要HA,好像不搞个HA都不好意思说自己的应用能承载高并发,大用户量访问.RabbitMQ这个经典的消息组件,也必然逃不掉单点失效的尴尬局面.当然在RabbitMQ在被广泛应用于 ...
- Kaggle(一):房价预测
Kaggle(一) 房价预测 (随机森林.岭回归.集成学习) 项目介绍:通过79个解释变量描述爱荷华州艾姆斯的住宅的各个方面,然后通过这些变量训练模型, 来预测房价. kaggle项目链接:ht ...
- 【原】Spring activiti 环境搭建之数据库创建
由于在开发工作流的时候,避免不了要保存一些数据和流程走向;所以在搭建Spring activiti开发环境的时候需要把官方提供的23张表创建到我们的DB,后续的流程都会在这些表中记录. 1.创建代码如 ...
- hdu 1978 How many ways 记忆化搜索 经典例题
How many ways Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Tot ...
- Android开发之旅1:环境搭建及HelloWorld
——工欲善其事必先利其器 引言 本系列适合0基础的人员,因为我就是从0开始的,此系列记录我步入Android开发的一些经验分享,望与君共勉!作为Android队伍中的一个新人的我,如果有什么不对的地方 ...
- 微信小程序之雪碧图(css script)
今天有朋友问我关于微信小程序中如何在不占用大量网络带宽的情况下快速加载图片,我给他推荐了两种方式 1.雪碧图(css script),有过前端经验的朋友应该都有接触过. 2.懒加载. 由于时间关系我就 ...
- xib Nib IB 可视化编程详解
简单的说,Xib就是拖控件编程,也可以说是可视化编程. 相对于代码,使用IB和xib文件来组织UI,可以省下大量代码和时间,从而得到更快的开发速度. 如果你曾经受到过微软家Visual Basic或者 ...

