Measuring or documenting something about your self such that it gains meaning.
Image metadata is text information pertaining to an image file that is embedded into the file or contained in a separate file that is associated with it.
Image metadata includes details relevant to the image itself as well as information about its production. This data is generated by the device capturing the image (i.e. the camera).
Metadata puts photos in context.
The photos on your mobile phone are one of the richest collections of data you have on yourself. If you regularly take photos with your phone (which most of us do), then your phone is collecting data on you.
//index.ios.js for start ios project
import { AppRegistry } from 'react-native';
import app from './app';
AppRegistry.registerComponent('rncameraroll', app);
CameraRoll provides access to the local camera roll / gallery.
Key Method: getPhotos()
https://facebook.github.io/react-native/docs/cameraroll.html
import React from 'react';
import { StackNavigator } from 'react-navigation'
import ImageBrowser from './ImageBrowser'
import ImageList from './ImageList'
const Navigation = StackNavigator({
ImageList: { screen: ImageList },
ImageBrowser: { screen: ImageBrowser },
});
function setup() {
return Navigation;
}
export default setup;
//imagelist.js for date list of photo on phone.
import React from 'react'
import { //import component
View,
Text,
TouchableOpacity,
StyleSheet,
Button,
CameraRoll,
Image,
Dimensions,
ScrollView,
ActivityIndicator,
Platform
} from 'react-native'
import App from './app'
import Utils from './utils'
const { width, height } = Dimensions.get('window')
export default class ImageList extends React.Component {
static navigationOptions = {
title: 'Gallery',
};
constructor(props) {
super(props);
this.state = {
dates: [],
photos: [],
loading: true
}
}
componentDidMount() {
this.getPhotos();
}
getPhotos = () => { //function getPhotos get photo from phone
CameraRoll.getPhotos({
first: Platform.OS === 'android' ? 999 : -1,
assetType: 'All',
// groupTypes: 'All'
})
.then(r => {
this.setState({ photos: r.edges });
r.edges.forEach(data => {
let dates = Utils.clone(this.state.dates);
let newTimestamp = data.node.timestamp;
let isDateExists = false;
if (dates.length) {
for (i = 0; i < dates.length; i++) {
let date = dates[i];
if (Utils.isSameDate(new Date(date.timestamp * 1000), new Date(newTimestamp * 1000))) {
date.count++;
isDateExists = true;
break;
}
}
}
if (!isDateExists) {
dates.push({
timestamp: newTimestamp,
count: 1
})
}
this.setState({ dates: dates, loading: false });
});
});
};
https://nativebase.io
// This method will generate a object structure for the image Object.
import Utils from "./utils.js";
import Exif from "react-native-exif";
import { Platform } from "react-native";
import { Crashlytics } from "react-native-fabric";
const imageObject = {
fetchObject(imageData) {
let cameraData = {
timestamp: imageData.timestamp,
groupName: imageData.group_name,
type: imageData.type,
location: imageData.location,
fileName: imageData.image.filename,
width: imageData.image.width,
height: imageData.image.height,
uri: imageData.image.uri,
isDeleted: false,
time: Utils.getStringTime(new Date(imageData.timestamp * 1000)),
date: Utils.getStringFromDate(new Date(imageData.timestamp * 1000)),
};
// alert(Utils.isExifDataDisable)
if(Utils.isExifDataDisable){
return new Promise((resolve, reject) => {
resolve(cameraData);
});
}else{
//adding the exif data in the image data fetched from CameraRoll
return new Promise((resolve, reject) => {
Exif.getExif(imageData.image.uri)
.then((data) =>{
cameraData = { ...cameraData, exifData:data };
resolve(cameraData);
})
.catch((error) => {
alert(error + " file: " + imageData.image.uri);
Platform.OS === "android"
// Record a non-fatal JS error
? Crashlytics.logException(error + " file: " + imageData.image.uri)
: Crashlytics.recordError(error + " file: " + imageData.image.uri)
// reject("Exif" + error);
resolve(cameraData);
});
});
}
},
};
module.exports = imageObject;
// This method will generate a object structure for the date Object.
const dateObject = {
fetchObject(timeStamp,imagesArray,count) {
return {
timestamp: timeStamp,
images: imagesArray,
};
}
};
module.exports = dateObject;
No backend. Store locally. Model data for exporting and stats.
Lessons? Next steps? Finding Insights from Photo Data?