Skip to content
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

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions appinfo/routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,12 @@
'url' => '/preview/{fileId}',
'verb' => 'GET'
],
// exif of picture
[
'name' => 'files#exif',
'url' => '/files/exif/{fileId}',
'verb' => 'GET'
],
/**
Copy link
Contributor

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

* Public services
*/
Expand Down Expand Up @@ -125,6 +131,12 @@
'url' => '/preview.public/{fileId}',
'verb' => 'GET'
],
// exif of picture
[
'name' => 'files_public#exif',
'url' => '/files.public/exif/{fileId}',
'verb' => 'GET'
],
/**
* API
*/
Expand Down
27 changes: 27 additions & 0 deletions controller/files.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does that work with encrypted files or files located on external storage?

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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
*
Expand Down
12 changes: 12 additions & 0 deletions controller/filespubliccontroller.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,18 @@
*/
class FilesPublicController extends FilesController {

/**
* @PublicPage
*
* Returns a exif of picture
*
* @param string $location a path picture
* @return array
*/
public function exif($fileId){
return parent::exif($fileId);
}

/**
* @PublicPage
*
Expand Down
7 changes: 5 additions & 2 deletions css/slideshow.css
Original file line number Diff line number Diff line change
Expand Up @@ -155,18 +155,21 @@
bottom: 18px;
z-index: 1099;
width: 100%;
height: 75px;
}

#slideshow > .name .title {
padding: 0 50px 3px;
position: absolute;
bottom: 0;
width: 100%;
padding: 0 1% 3px;
text-align: center;
color: #fff;
text-shadow: 1px 1px 4px #333, 1px -1px 4px #333, -1px 1px 4px #333, -1px -1px 4px #333;
font-size: 18px;
line-height: normal;
text-overflow: ellipsis;
overflow: hidden;
white-space: nowrap;
filter: alpha(opacity=75);
opacity: .75;
}
Expand Down
2 changes: 1 addition & 1 deletion js/gallery.js
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@
return {
name: name,
path: image.path,
file: image.fileId,
fileId: image.fileId,
mimeType: image.mimeType,
url: previewUrl,
downloadUrl: downloadUrl
Expand Down
36 changes: 36 additions & 0 deletions js/slideshow.js
Original file line number Diff line number Diff line change
Expand Up @@ -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){
Copy link
Contributor

Choose a reason for hiding this comment

The 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

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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);
Expand Down
7 changes: 6 additions & 1 deletion js/slideshowcontrols.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,12 @@
if (this.playing) {
this._setTimeout();
}
this._setName(currentImage.name);
// check exif descr
if (currentImage.desc){
this._setName(currentImage.desc);
}else{
this._setName(currentImage.name);
}
},

/**
Expand Down