diff --git a/appinfo/routes.php b/appinfo/routes.php index 7c968905c..7fb222349 100644 --- a/appinfo/routes.php +++ b/appinfo/routes.php @@ -96,6 +96,12 @@ 'url' => '/preview/{fileId}', 'verb' => 'GET' ], + // exif of picture + [ + 'name' => 'files#exif', + 'url' => '/files/exif/{fileId}', + 'verb' => 'GET' + ], /** * Public services */ @@ -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 */ diff --git a/css/slideshow.css b/css/slideshow.css index 61a1dd034..65fb97b4e 100644 --- a/css/slideshow.css +++ b/css/slideshow.css @@ -134,10 +134,14 @@ 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; @@ -146,6 +150,7 @@ text-overflow: ellipsis; overflow: hidden; white-space: nowrap; + filter: alpha(opacity=75); opacity: .75; } diff --git a/js/gallery.js b/js/gallery.js index ac0062c15..19b389792 100644 --- a/js/gallery.js +++ b/js/gallery.js @@ -297,7 +297,7 @@ return { name: name, path: image.path, - file: image.fileId, + fileId: image.fileId, mimeType: image.mimeType, permissions: image.permissions, url: previewUrl, diff --git a/js/slideshow.js b/js/slideshow.js index 1ddf367c4..04c46ea40 100644 --- a/js/slideshow.js +++ b/js/slideshow.js @@ -113,6 +113,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) { + 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, Gallery.token, image.permissions); diff --git a/js/slideshowcontrols.js b/js/slideshowcontrols.js index a27452413..42616e8e2 100644 --- a/js/slideshowcontrols.js +++ b/js/slideshowcontrols.js @@ -97,7 +97,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); + } }, /** diff --git a/lib/Controller/Files.php b/lib/Controller/Files.php index 7e9cf60bb..e5c73f3e2 100644 --- a/lib/Controller/Files.php +++ b/lib/Controller/Files.php @@ -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->getFile($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); + } + getimagesize($filename,$blocks); + if (is_array($blocks)) { + foreach($blocks as $key => $block) { + $iptc[$key]=iptcparse($block); + } + } + return ['exif'=>$exif,'iptc'=>$iptc]; + } + /** * @NoAdminRequired * diff --git a/lib/Controller/FilesPublicController.php b/lib/Controller/FilesPublicController.php index a34b6b041..c33ad2939 100644 --- a/lib/Controller/FilesPublicController.php +++ b/lib/Controller/FilesPublicController.php @@ -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 *