-
Notifications
You must be signed in to change notification settings - Fork 65
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[+] Exif Description #453
base: master
Are you sure you want to change the base?
[+] Exif Description #453
Changes from 1 commit
b0eeab0
6542b1e
cb06815
d3f057c
93fc021
cbdca38
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -45,6 +45,30 @@ trait Files { | |
/** @var ILogger */ | ||
private $logger; | ||
|
||
/** | ||
* @NoAdminRequired | ||
* | ||
* Returns a exif of picture | ||
* | ||
* @param string $location a path picture | ||
* @return array | ||
*/ | ||
public function exif($location){ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's best to use the file's ID There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done |
||
$filename=\OC\Files\Filesystem::getLocalFile($location); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We cannot use private APIs |
||
$exif = false; | ||
$iptc = false; | ||
if (is_callable('exif_read_data')) { | ||
$exif=@exif_read_data($filename); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does that work with encrypted files or files located on external storage? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes. for external "local" return direct path, for external nonlocal return path to cached file. |
||
} | ||
getimagesize($filename,$info); | ||
if (is_array($info)){ | ||
foreach($info as $k => $i){ | ||
$iptc[$k]=iptcparse($i); | ||
} | ||
} | ||
return ['exif'=>$exif,'iptc'=>$iptc]; | ||
} | ||
|
||
/** | ||
* @NoAdminRequired | ||
* | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -103,6 +103,38 @@ | |
|
||
// check if we moved along while we were loading | ||
if (currentImageId === index) { | ||
// check if not in cache | ||
if (this.images[index].desc===undefined){ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We need to make sure we only send the request when we have a media type which supports meta data There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done |
||
var params={location:this.images[index].path} | ||
var url=OC.generateUrl('apps/gallery/files/exif?location={location}', params); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's best to use something like this There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. buildGalleryUrl is defined in galleryutility.js, but its not included in /apps/files. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah, yes, you're correct. I keep having to duplicate methods because we don't load too many files on the files side. |
||
$.getJSON(url).then(function(data){ | ||
console.log(data); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. To be removed at the end of the process There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done |
||
var d; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would prefer it if the variable is more descriptive There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done |
||
if (data){ | ||
// IPTC:Description (Picasa, Photoshop, Lightroom) | ||
if (data['iptc']&&data['iptc']['APP13']&&data['iptc']['APP13']['2#120']){ | ||
d=data['iptc']['APP13']['2#120'][0]; | ||
} | ||
// EXIF:Description (old camera model) | ||
if (!d){ | ||
if (data['exif']&&data['exif']['ImageDescription']) | ||
d=data['exif']['ImageDescription']; | ||
} | ||
if (d){ | ||
this.images[index].desc=d; | ||
this.controls.show(currentImageId); | ||
this._initControlsAutoFader(); | ||
this.container.removeClass('inactive'); | ||
}else{ | ||
this.images[index].desc=''; | ||
} | ||
} | ||
}.bind(this)); | ||
}else if (this.images[index].desc){ | ||
this.controls.show(currentImageId); | ||
this._initControlsAutoFader(); | ||
this.container.removeClass('inactive'); | ||
} | ||
var image = this.images[index]; | ||
var transparent = this._isTransparent(image.mimeType); | ||
this.controls.showActionButtons(transparent); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The public routes will need the same endpoint
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done