-
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 all commits
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,33 @@ trait Files { | |
/** @var ILogger */ | ||
private $logger; | ||
|
||
/** | ||
* @NoAdminRequired | ||
* | ||
* Returns a exif of picture | ||
* | ||
* @param string $location a path picture | ||
* @return array | ||
*/ | ||
public function exif($fileId){ | ||
$file = $this->downloadService->getResourceFromId($fileId); | ||
$path=$file->getInternalPath(); | ||
$storage=$file->getStorage(); | ||
$filename=$storage->getLocalFile($path); | ||
$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,$blocks); | ||
if (is_array($blocks)){ | ||
foreach($blocks as $key => $block){ | ||
$iptc[$key]=iptcparse($block); | ||
} | ||
} | ||
return ['exif'=>$exif,'iptc'=>$iptc]; | ||
} | ||
|
||
/** | ||
* @NoAdminRequired | ||
* | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -103,6 +103,42 @@ | |
|
||
// check if we moved along while we were loading | ||
if (currentImageId === index) { | ||
if (this.images[index].mimeType === 'image/jpeg' || this.images[index].mimeType === 'image/tiff'){ | ||
// 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 |
||
if (window.galleryFileAction){ | ||
var url = window.galleryFileAction.buildGalleryUrl('files', '/exif/'+this.images[index].fileId,{}); | ||
}else{ | ||
var url = window.Gallery.utility.buildGalleryUrl('files', '/exif/'+this.images[index].fileId,{}); | ||
} | ||
$.getJSON(url).then(function(data){ | ||
var desc; | ||
if (data){ | ||
// IPTC:Description (Picasa, Photoshop, Lightroom) | ||
if (data['iptc']&&data['iptc']['APP13']&&data['iptc']['APP13']['2#120']){ | ||
desc=data['iptc']['APP13']['2#120'][0]; | ||
} | ||
// EXIF:Description (old camera model) | ||
if (!desc){ | ||
if (data['exif']&&data['exif']['ImageDescription']) | ||
desc=data['exif']['ImageDescription']; | ||
} | ||
if (desc){ | ||
this.images[index].desc=desc; | ||
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