以下是image我试图从。
中提取非标准字段我试图在iOS上使用这种方法获取元数据。
CGImageSourceRef source = CGImageSourceCreateWithData((CFDataRef)imageData, nil);
NSDictionary *metadata = (NSDictionary *)CFBridgingRelease(CGImageSourceCopyPropertiesAtIndex(source, 0, nil));
但它不包含以上属性。 任何帮助表示赞赏。
答案 0 :(得分:0)
您正希望从图片中获取EXIF数据。这是执行此操作的一些Playground代码:
//: Playground - noun: a place where people can play
import UIKit
let url:NSURL = URL(string:"https://mobilesecurity.win/samples/EXIF_example.jpg")! as NSURL
let imageSource = CGImageSourceCreateWithURL(url, nil)!
let imageProperties = CGImageSourceCopyPropertiesAtIndex(imageSource, 0, nil) as! [String:Any]
for (key, value) in imageProperties {
print("\(key) = \(value)")
}
在上面的示例图片中,结果如下:
PixelHeight = 3024
{Exif} = {
ApertureValue = "1.695993715632365";
BrightnessValue = "7.553953257086027";
ColorSpace = 65535;
ComponentsConfiguration = (
1,
2,
3,
0
);
CustomRendered = 2;
DateTimeDigitized = "2018:05:05 16:58:33";
DateTimeOriginal = "2018:05:05 16:58:33";
DigitalZoomRatio = "1.212510024057739";
ExifVersion = (
2,
2,
1
);
ExposureBiasValue = 0;
ExposureMode = 0;
ExposureProgram = 2;
ExposureTime = "0.003355704697986577";
FNumber = "1.8";
Flash = 24;
FlashPixVersion = (
1,
0
);
FocalLenIn35mmFilm = 34;
FocalLength = "3.99";
ISOSpeedRatings = (
20
);
LensMake = Apple;
LensModel = "iPhone 8 Plus back dual camera 3.99mm f/1.8";
LensSpecification = (
"3.99",
"6.6",
"1.8",
"2.8"
);
MeteringMode = 5;
PixelXDimension = 4032;
PixelYDimension = 3024;
SceneCaptureType = 0;
SceneType = 1;
SensingMethod = 2;
ShutterSpeedValue = "8.219041278295606";
SubjectArea = (
2483,
33,
292,
296
);
SubsecTimeDigitized = 269;
SubsecTimeOriginal = 269;
WhiteBalance = 0;
}
DPIWidth = 72
Depth = 8
{ExifAux} = {
Regions = {
HeightAppliedTo = 3024;
RegionList = (
{
AngleInfoRoll = 270;
AngleInfoYaw = 270;
ConfidenceLevel = 99;
FaceID = 29;
Height = "0.06024057738572575";
Timestamp = 2147483647;
Type = Face;
Width = "0.07273601924233319";
X = "0.6160769693325315";
Y = "0.03012028869286288";
},
{
AngleInfoRoll = 270;
AngleInfoYaw = 315;
ConfidenceLevel = 99;
FaceID = 30;
Height = "0.08487570168404171";
Timestamp = 2147483647;
Type = Face;
Width = "0.06303788334335536";
X = "0.5821334936861094";
Y = "0.2045292702485966";
},
{
AngleInfoRoll = 240;
AngleInfoYaw = 0;
ConfidenceLevel = 99;
FaceID = 31;
Height = "0.07153809141940659";
Timestamp = 2147483647;
Type = Face;
Width = "0.05333974744437764";
X = "0.4718171978352376";
Y = "0.8029029671210907";
}
);
WidthAppliedTo = 4032;
};
}
Orientation = 6
ProfileName = Display P3
{MakerApple} = {
1 = 9;
10 = 2;
12 = (
"7.1875",
"31.75391"
);
13 = 38;
14 = 4;
16 = 1;
2 = <8e021002 6c011b02 d7005f00 4402e002 54016a00 36004700 4b003e00 2e002600 a101a201 8801ab01 85005900 3a02cf02 b0005900 95007600 2e002400 2d008300 cc031d02 2101d800 79005b00 1602fe02 4702b200 bd006900 29001600 67008700 17056f02 4901a200 65006d00 60026202 02026000 55003100 3e004500 99009000 43048b01 b201cc00 7d008400 6202f201 c4019500 24022500 46005000 4f004700 3f02af01 0e01cb00 79007e00 54024e03 bb01b400 dc001900 60005500 22001600 5c014d01 6601d700 77007800 68028402 03017700 55002600 25003700 2b001800 6e019f01 4f011701 79007900 d8001501 bd003b00 6c005300 2f002f00 26002600 4902f401 69020d01 89005300 4d01e200 4c005c00 91005700 36002100 1c002c00 8b01ce01 b8014400 5d007900 8c004f00 9a007700 ad003500 29004000 2a001900 bd017c01 32013e00 36006200 7e008f00 62004100 86002400 34004800 26001b00 eb01a101 f8003b00 35003b00 ca010a01 8f007700 7b002c00 33005100 36002e00 5e017501 47013900 34003800 d901d101 7f005200 22001b00 23002000 22002a00 0501d700 b4003800 33003800 a501b300 92005300 20001800 36002500 19001600 fa012201 59003700 33003600 26016f00 cc009600 2d001400 27003100 20001900 f300a300 3f003600 33003500 2a01cc00 d200b700 3f001c00 30002400 1f002000>;
20 = 3;
22 = "AR1G+K438OnfHOzqQ+UT5Ix1ijDD";
23 = 0;
25 = 2;
26 = q825s;
3 = {
epoch = 0;
flags = 1;
timescale = 1000000000;
value = 93963587977416;
};
31 = 0;
4 = 1;
5 = 178;
6 = 175;
7 = 1;
8 = (
"-0.02829843",
"-0.9835473",
"-0.1944532"
);
}
{TIFF} = {
DateTime = "2018:05:05 16:58:33";
Make = Apple;
Model = "iPhone 8 Plus";
Orientation = 6;
ResolutionUnit = 2;
Software = "11.3.1";
XResolution = 72;
YResolution = 72;
}
ColorModel = RGB
DPIHeight = 72
PixelWidth = 4032
EXIF数据中的特定字段取决于图像的制作者。我不知道&#39; Image Unique Id&#39;本质上是图像的一部分,因此它的存在取决于拍摄图片的设备。