From b0eeab0adda5b2d92c69f8f8a17cbb9a0ea88b4d Mon Sep 17 00:00:00 2001 From: 0xb0ba Date: Tue, 27 Oct 2015 16:09:39 +0500 Subject: [PATCH 1/6] [+] Exif Description --- appinfo/routes.php | 6 ++++++ controller/files.php | 24 ++++++++++++++++++++++++ js/slideshow.js | 32 ++++++++++++++++++++++++++++++++ js/slideshowcontrols.js | 7 ++++++- 4 files changed, 68 insertions(+), 1 deletion(-) diff --git a/appinfo/routes.php b/appinfo/routes.php index 403b9dd581..9dd22c7150 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', + 'verb' => 'GET' + ], /** * Public services */ diff --git a/controller/files.php b/controller/files.php index 1777523e3a..49a186d0fd 100644 --- a/controller/files.php +++ b/controller/files.php @@ -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){ + $filename=\OC\Files\Filesystem::getLocalFile($location); + $exif = false; + $iptc = false; + if (is_callable('exif_read_data')) { + $exif=@exif_read_data($filename); + } + getimagesize($filename,$info); + if (is_array($info)){ + foreach($info as $k => $i){ + $iptc[$k]=iptcparse($i); + } + } + return ['exif'=>$exif,'iptc'=>$iptc]; + } + /** * @NoAdminRequired * diff --git a/js/slideshow.js b/js/slideshow.js index 8cd07b352c..536dbae249 100644 --- a/js/slideshow.js +++ b/js/slideshow.js @@ -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){ + var params={location:this.images[index].path} + var url=OC.generateUrl('apps/gallery/files/exif?location={location}', params); + $.getJSON(url).then(function(data){ + console.log(data); + var d; + 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); diff --git a/js/slideshowcontrols.js b/js/slideshowcontrols.js index 3dead6e2e9..ef31df8eea 100644 --- a/js/slideshowcontrols.js +++ b/js/slideshowcontrols.js @@ -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); + } }, /** From 6542b1eed5d3ee59586630984992c17eb94a1b74 Mon Sep 17 00:00:00 2001 From: 0xb0ba Date: Wed, 28 Oct 2015 01:34:29 +0500 Subject: [PATCH 2/6] comments from oparoz --- appinfo/routes.php | 8 +++++++- controller/files.php | 19 ++++++++++--------- js/gallery.js | 2 +- js/slideshow.js | 18 ++++++++++-------- 4 files changed, 28 insertions(+), 19 deletions(-) diff --git a/appinfo/routes.php b/appinfo/routes.php index 9dd22c7150..4efa999849 100644 --- a/appinfo/routes.php +++ b/appinfo/routes.php @@ -99,7 +99,7 @@ // exif of picture [ 'name' => 'files#exif', - 'url' => '/files/exif', + 'url' => '/files/exif/{fileId}', 'verb' => 'GET' ], /** @@ -131,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/controller/files.php b/controller/files.php index 49a186d0fd..691b3188c3 100644 --- a/controller/files.php +++ b/controller/files.php @@ -53,21 +53,22 @@ trait Files { * @param string $location a path picture * @return array */ - public function exif($location){ - $filename=\OC\Files\Filesystem::getLocalFile($location); - $exif = false; + public function exif($fileId){ + $path=\OC\Files\Filesystem::getPath($fileId); + $filename=\OC\Files\Filesystem::getLocalFile($path); + $exif = false; $iptc = false; if (is_callable('exif_read_data')) { $exif=@exif_read_data($filename); } - getimagesize($filename,$info); - if (is_array($info)){ - foreach($info as $k => $i){ - $iptc[$k]=iptcparse($i); + getimagesize($filename,$blocks); + if (is_array($blocks)){ + foreach($blocks as $key => $block){ + $iptc[$key]=iptcparse($block); } } - return ['exif'=>$exif,'iptc'=>$iptc]; - } + return ['exif'=>$exif,'iptc'=>$iptc]; + } /** * @NoAdminRequired diff --git a/js/gallery.js b/js/gallery.js index caea603191..8bb70c86ad 100644 --- a/js/gallery.js +++ b/js/gallery.js @@ -346,7 +346,7 @@ return { name: name, path: image.path, - file: image.fileId, + fileId: image.fileId, mimeType: image.mimeType, url: previewUrl, downloadUrl: downloadUrl diff --git a/js/slideshow.js b/js/slideshow.js index 536dbae249..32741b2919 100644 --- a/js/slideshow.js +++ b/js/slideshow.js @@ -103,25 +103,26 @@ // 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){ - var params={location:this.images[index].path} - var url=OC.generateUrl('apps/gallery/files/exif?location={location}', params); + var params={fileid:this.images[index].fileId} + var url=OC.generateUrl('apps/gallery/files/exif/{fileid}', params); $.getJSON(url).then(function(data){ console.log(data); - var d; + var desc; 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]; + desc=data['iptc']['APP13']['2#120'][0]; } // EXIF:Description (old camera model) - if (!d){ + if (!desc){ if (data['exif']&&data['exif']['ImageDescription']) - d=data['exif']['ImageDescription']; + desc=data['exif']['ImageDescription']; } - if (d){ - this.images[index].desc=d; + if (desc){ + this.images[index].desc=desc; this.controls.show(currentImageId); this._initControlsAutoFader(); this.container.removeClass('inactive'); @@ -135,6 +136,7 @@ this._initControlsAutoFader(); this.container.removeClass('inactive'); } + } var image = this.images[index]; var transparent = this._isTransparent(image.mimeType); this.controls.showActionButtons(transparent); From cb068152349d532ef74620be1b0ef400eb60fee7 Mon Sep 17 00:00:00 2001 From: 0xb0ba Date: Wed, 28 Oct 2015 01:41:27 +0500 Subject: [PATCH 3/6] remove debug --- js/slideshow.js | 1 - 1 file changed, 1 deletion(-) diff --git a/js/slideshow.js b/js/slideshow.js index 32741b2919..c259f7d6b2 100644 --- a/js/slideshow.js +++ b/js/slideshow.js @@ -109,7 +109,6 @@ var params={fileid:this.images[index].fileId} var url=OC.generateUrl('apps/gallery/files/exif/{fileid}', params); $.getJSON(url).then(function(data){ - console.log(data); var desc; if (data){ // IPTC:Description (Picasa, Photoshop, Lightroom) From d3f057c31eb2a19a74b8052be7a26d3893e59c22 Mon Sep 17 00:00:00 2001 From: 0xb0ba Date: Wed, 28 Oct 2015 11:20:37 +0500 Subject: [PATCH 4/6] Node API here instead of a private API --- controller/files.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/controller/files.php b/controller/files.php index 691b3188c3..264cde47ad 100644 --- a/controller/files.php +++ b/controller/files.php @@ -54,8 +54,10 @@ trait Files { * @return array */ public function exif($fileId){ - $path=\OC\Files\Filesystem::getPath($fileId); - $filename=\OC\Files\Filesystem::getLocalFile($path); + $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')) { From 93fc0217384c18201411742fef3b5021dda8b3d1 Mon Sep 17 00:00:00 2001 From: 0xb0ba Date: Thu, 29 Oct 2015 11:53:48 +0500 Subject: [PATCH 5/6] 3 line for description --- css/slideshow.css | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/css/slideshow.css b/css/slideshow.css index 4ce8677f45..e3c239855a 100644 --- a/css/slideshow.css +++ b/css/slideshow.css @@ -155,10 +155,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; @@ -166,7 +170,6 @@ line-height: normal; text-overflow: ellipsis; overflow: hidden; - white-space: nowrap; filter: alpha(opacity=75); opacity: .75; } From cbdca38284b9c856d2f1324b981c32db7c177026 Mon Sep 17 00:00:00 2001 From: 0xb0ba Date: Mon, 2 Nov 2015 14:52:46 +0500 Subject: [PATCH 6/6] description for public galleries --- controller/filespubliccontroller.php | 12 ++++++++++++ js/slideshow.js | 7 +++++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/controller/filespubliccontroller.php b/controller/filespubliccontroller.php index 90c06a1a49..0359ebb422 100644 --- a/controller/filespubliccontroller.php +++ b/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 * diff --git a/js/slideshow.js b/js/slideshow.js index c259f7d6b2..4d5625cf2c 100644 --- a/js/slideshow.js +++ b/js/slideshow.js @@ -106,8 +106,11 @@ if (this.images[index].mimeType === 'image/jpeg' || this.images[index].mimeType === 'image/tiff'){ // check if not in cache if (this.images[index].desc===undefined){ - var params={fileid:this.images[index].fileId} - var url=OC.generateUrl('apps/gallery/files/exif/{fileid}', params); + 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){