我正在尝试使用ALAssetLibrary在我的应用程序中显示相机胶卷中的照片。除裁剪的图像外,所有图像都显示正常。使用fullResolutionImage
ALAssetRepresentation
方法而不是裁剪版本时,ALAsset会返回未经编辑的图像版本。
所以我试图从其元数据中提取ALAsset
个对象的裁剪信息。我用Google搜索并发现裁剪信息包含在AdjustmentXMP
对象的元数据的ALAssetRepresentation
键中。使用上面的信息我可以在我的应用程序中正确显示裁剪的图像,但在v5.1及更高版本上的方法,但在iOS v5.0上失败。
iOS 5.1上裁剪图像的元数据字典:
{
AdjustmentXMP = "<x:xmpmeta xmlns:x=\"adobe:ns:meta/\" x:xmptk=\"XMP Core 4.4.0\">\n <rdf:RDF xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\">\n <rdf:Description rdf:about=\"\"\n xmlns:aas=\"http://ns.apple.com/adjustment-settings/1.0/\">\n <aas:AffineA>1</aas:AffineA>\n <aas:AffineB>0</aas:AffineB>\n <aas:AffineC>0</aas:AffineC>\n <aas:AffineD>1</aas:AffineD>\n <aas:AffineX>-266</aas:AffineX>\n <aas:AffineY>-589</aas:AffineY>\n <aas:CropX>0</aas:CropX>\n <aas:CropY>0</aas:CropY>\n <aas:CropW>270</aas:CropW>\n <aas:CropH>162</aas:CropH>\n </rdf:Description>\n </rdf:RDF>\n</x:xmpmeta>\n";
ColorModel = RGB;
DPIHeight = 72;
DPIWidth = 72;
Depth = 8;
Orientation = 1;
PixelHeight = 1024;
PixelWidth = 768;
"{Exif}" = {
ApertureValue = "2.526069";
BrightnessValue = "0.1544926";
ColorSpace = 1;
ComponentsConfiguration = (
0,
0,
0,
1
);
DateTimeDigitized = "2013:01:22 14:12:59";
DateTimeOriginal = "2013:01:22 14:12:59";
ExifVersion = (
2,
2
);
ExposureMode = 0;
ExposureProgram = 2;
ExposureTime = "0.06666667";
FNumber = "2.4";
Flash = 16;
FlashPixVersion = (
1,
0
);
FocalLenIn35mmFilm = 33;
FocalLength = "4.13";
ISOSpeedRatings = (
400
);
MeteringMode = 5;
PixelXDimension = 768;
PixelYDimension = 1024;
SceneCaptureType = 0;
SensingMethod = 2;
ShutterSpeedValue = "3.906905";
SubjectArea = (
1631,
1223,
881,
881
);
WhiteBalance = 0;
};
"{GPS}" = {
Altitude = "216.1379";
AltitudeRef = 0;
DateStamp = "2013:01:22";
Latitude = "28.46366666666667";
LatitudeRef = N;
Longitude = "77.04916666666666";
LongitudeRef = E;
TimeStamp = "08:42:56.00";
};
"{TIFF}" = {
DateTime = "2013:01:22 14:14:39";
Make = Apple;
Model = "iPhone 5";
Orientation = 1;
ResolutionUnit = 2;
Software = "QuickTime 7.7.1";
XResolution = 72;
YResolution = 72;
"_YCbCrPositioning" = 1;
};
}
iOS 5.0.1上裁剪图像的元数据字典:
Metadata: {
ColorModel = RGB;
Depth = 8;
PixelHeight = 2048;
PixelWidth = 1078;
"{JFIF}" = {
DensityUnit = 0;
JFIFVersion = (
1,
1
);
XDensity = 1;
YDensity = 1;
};
}
如上所述,v5.1上的元数据字典包含AdjustmentXMP
,其中包含裁剪信息,而v5.0上的相同字典没有AdjustmentXMP
密钥。因此,在v5.0.1上裁剪失败。
有关如何在iOS v5.0.1及更低版本的设备上显示裁剪图像的任何指示?