mirror of
https://github.com/flynx/ImageGrid.git
synced 2025-10-29 10:20:08 +00:00
refactoring exif feature...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
65e3ae1cb9
commit
5bbe479fcb
@ -24,19 +24,68 @@ var core = require('features/core')
|
|||||||
|
|
||||||
|
|
||||||
/*********************************************************************/
|
/*********************************************************************/
|
||||||
|
// XXX rename: EXIF -> Metadata
|
||||||
|
// XXX make metadata a prop of image...
|
||||||
|
|
||||||
// XXX split this into two:
|
|
||||||
// - getter from .images[gid].metadata (no external dependencies)
|
|
||||||
// - fileExifExtractor / webExifExtractor / ... to implement
|
|
||||||
// extracting of exif if .metadata does not exist...
|
|
||||||
// XXX add exif writer...
|
|
||||||
var EXIFActions = actions.Actions({
|
var EXIFActions = actions.Actions({
|
||||||
// XXX cache the result and see if it is cached before running exiftool...
|
getExif: ['- Image/Get exif data',
|
||||||
|
function(image){
|
||||||
|
var gid = this.data.getImage(image)
|
||||||
|
|
||||||
|
if(this.images && this.images[gid]){
|
||||||
|
return this.images[gid].metadata || {}
|
||||||
|
}
|
||||||
|
return null
|
||||||
|
}],
|
||||||
|
setExif: ['- Image/Set exif data',
|
||||||
|
function(image, metadata, merge){
|
||||||
|
var that = this
|
||||||
|
var gid = this.data.getImage(image)
|
||||||
|
|
||||||
|
if(this.images && this.images[gid]){
|
||||||
|
if(merge){
|
||||||
|
var m = this.images[gid].metadata
|
||||||
|
Object.keys(metadata).forEach(function(k){
|
||||||
|
m[k] = metadata[k]
|
||||||
|
})
|
||||||
|
|
||||||
|
} else {
|
||||||
|
this.images[gid].metadata = metadata
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}]
|
||||||
|
})
|
||||||
|
|
||||||
|
var EXIF =
|
||||||
|
module.EXIF = core.ImageGridFeatures.Feature({
|
||||||
|
title: '',
|
||||||
|
doc: '',
|
||||||
|
|
||||||
|
tag: 'exif',
|
||||||
|
depends: [
|
||||||
|
'base',
|
||||||
|
],
|
||||||
|
|
||||||
|
isApplicable: function(){
|
||||||
|
return this.runtime == 'nw' || this.runtime == 'node' },
|
||||||
|
|
||||||
|
actions: EXIFActions,
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------
|
||||||
|
// Exif reader/writer...
|
||||||
|
|
||||||
|
|
||||||
|
// XXX add exif writer...
|
||||||
|
var EXIFReaderActions = actions.Actions({
|
||||||
|
// XXX should this be sync???
|
||||||
|
// XXX should this process multiple images???
|
||||||
// XXX also check the metadata/ folder (???)
|
// XXX also check the metadata/ folder (???)
|
||||||
// XXX this uses .markChanged(..) form filesystem.FileSystemWriter
|
// XXX this uses .markChanged(..) form filesystem.FileSystemWriter
|
||||||
// feature, but technically does not depend on it...
|
// feature, but technically does not depend on it...
|
||||||
// XXX should we store metadata in an image (current) or in fs???
|
// XXX should we store metadata in an image (current) or in fs???
|
||||||
getExif: ['- Image/Get exif data',
|
readExif: ['- Image/Get exif data',
|
||||||
function(image, force){
|
function(image, force){
|
||||||
var that = this
|
var that = this
|
||||||
|
|
||||||
@ -75,18 +124,18 @@ var EXIFActions = actions.Actions({
|
|||||||
}],
|
}],
|
||||||
|
|
||||||
// XXX take image exif and write it to target...
|
// XXX take image exif and write it to target...
|
||||||
setExif: ['- Image/Set exif data',
|
writeExif: ['- Image/Set exif data',
|
||||||
function(image, target){
|
function(image, target){
|
||||||
// XXX
|
// XXX
|
||||||
}]
|
}]
|
||||||
})
|
})
|
||||||
|
|
||||||
var EXIF =
|
var EXIFReader =
|
||||||
module.EXIF = core.ImageGridFeatures.Feature({
|
module.EXIF = core.ImageGridFeatures.Feature({
|
||||||
title: '',
|
title: '',
|
||||||
doc: '',
|
doc: '',
|
||||||
|
|
||||||
tag: 'exif',
|
tag: 'exif-reader',
|
||||||
depends: [
|
depends: [
|
||||||
'base',
|
'base',
|
||||||
],
|
],
|
||||||
@ -94,10 +143,11 @@ module.EXIF = core.ImageGridFeatures.Feature({
|
|||||||
isApplicable: function(){
|
isApplicable: function(){
|
||||||
return this.runtime == 'nw' || this.runtime == 'node' },
|
return this.runtime == 'nw' || this.runtime == 'node' },
|
||||||
|
|
||||||
actions: EXIFActions,
|
actions: EXIFReaderActions,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------
|
//---------------------------------------------------------------------
|
||||||
// Exif editor/viewer...
|
// Exif editor/viewer...
|
||||||
//
|
//
|
||||||
|
|||||||
@ -276,6 +276,26 @@ module.makeImageSeqOrNameCmp = function(data, get, seq){
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*********************************************************************/
|
||||||
|
// XXX Image base class...
|
||||||
|
// ...not sure if we need this... (???)
|
||||||
|
|
||||||
|
var ImageClassPrototype =
|
||||||
|
module.ImageClassPrototype = {
|
||||||
|
}
|
||||||
|
|
||||||
|
var ImagePrototype =
|
||||||
|
module.ImagePrototype = {
|
||||||
|
}
|
||||||
|
|
||||||
|
var Image =
|
||||||
|
module.Image =
|
||||||
|
object.makeConstructor('Image',
|
||||||
|
ImageClassPrototype,
|
||||||
|
ImagePrototype)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*********************************************************************/
|
/*********************************************************************/
|
||||||
|
|
||||||
// XXX depends on jli.quoteRegExp(..)
|
// XXX depends on jli.quoteRegExp(..)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user