Информация: Использование Swift и функция CGImageSourceCreateWithURL.Swift accesing EXIF Dictionary
Я пытаюсь загрузить файл с URL-адреса, а затем отредактировать словарь, который имеет все данные с этой конкретной фотографии.
Это код из файла .swift. не
let url = NSURL(string: "http://jwphotographic.co.uk/Images/1.jpg")
let imageSource = CGImageSourceCreateWithURL(url, nil)
let imageProperties = CGImageSourceCopyPropertiesAtIndex(imageSource, 0, nil) as Dictionary
println(imageProperties)
//this is an example
let aperture = imageProperties[kCGImagePropertyGPSLatitude] as! NSNumber!
/*
//these are all being defined as nil
//Load the ones from the exif data of the file
let lensUsed = imageProperties[kCGImagePropertyExifFocalLength]
let aperture = imageProperties[kCGImagePropertyExifApertureValue] as!
let isoSpeed = imageProperties[kCGImagePropertyExifISOSpeedRatings] as! NSNumber
let latitude = imageProperties[kCGImagePropertyGPSLatitude] as! NSNumber
let longitude = imageProperties[kCGImagePropertyGPSLongitude] as! NSNumber
let shutterSpeed = imageProperties[kCGImagePropertyExifShutterSpeedValue] as! NSNumber
let cameraName = imageProperties[kCGImagePropertyExifBodySerialNumber] as! NSNumber
*/
println(aperture)
Даже если изображения свойства печатает все данные, как можно было бы ожидать, не-независимо от того, что я attmpted извлечь из словаря ImageProperties - это всегда возвращается как нуль - такие, как «отверстие» в примере. ImageProperties печатает как;
[{TIFF}: {
Artist = JOHN;
Copyright = "[email protected]";
DateTime = "2015:07:31 21:07:05";
Make = Canon;
Model = "Canon EOS 7D Mark II";
ResolutionUnit = 2;
Software = "Adobe Photoshop Lightroom 6.0 (Macintosh)";
XResolution = 72;
YResolution = 72;
}, {IPTC}: {
Byline = (
JOHN
);
CopyrightNotice = etc.. etc..
Я сделал много исследований и испытаний, и я просто не могу работать, что я делаю неправильно, чтобы получить доступ к элементам в этом словаре - Может кто-нибудь дать мне пример того, как я хотел бы установить переменную в качестве Элемент «Модель» внутри словаря?
Спасибо за любую помощь, Джон
Есть ли способ получить информацию о фото из библиотеки фотографий? Спасибо –
Да, я отредактировал свой ответ, чтобы показать пример о том, как это сделать в последнем Swift/Xcode – Cortex