जानकारी: स्विफ्ट और CGImageSourceCreateWithURL फ़ंक्शन का उपयोग करना।स्विफ्ट accesing EXIF शब्दकोश
मैं एक यूआरएल से एक फ़ाइल लोड करने का प्रयास कर रहा हूं और फिर उस शब्दकोश को संपादित कर रहा हूं जिसमें उस विशेष तस्वीर से सभी डेटा हैं।
यह .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)
हालांकि छवि गुण सभी डेटा के रूप में उम्मीद होगी प्रिंट, कोई बात नहीं क्या मैं imageProperties शब्दकोश से निकालने के लिए attmpted है - इस तरह के उदाहरण में 'एपर्चर' के रूप में - यह हमेशा अशक्त के रूप में दिया जाता है। छविप्रॉपर्टीज प्रिंट करता है;
[{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..
मैं अनुसंधान और परीक्षण का एक बहुत किया है और मैं बस से बाहर काम नहीं कर सकता मैं इस शब्दकोश में तत्वों का उपयोग करने की गलत क्या कर रही हूं - किसी ने मुझे एक उदाहरण देता हूँ सकता है कि कैसे मैं के रूप में एक चर सेट हैं शब्दकोश के अंदर "मॉडल" तत्व?
किसी भी मदद के लिए धन्यवाद, जॉन
क्या फोटो लाइब्रेरी से कैमरा जानकारी प्राप्त करने का कोई तरीका है? धन्यवाद –
हां, मैंने नवीनतम उत्तर/एक्सकोड में इसे कैसे किया जाए इस पर एक उदाहरण दिखाने के लिए अपना जवाब संपादित किया है – Cortex