From 88c687a3d148cbca9b08dfe6ed426a066148d161 Mon Sep 17 00:00:00 2001 From: Andy Heathershaw Date: Sat, 16 Sep 2017 12:49:34 +0100 Subject: [PATCH] #38, #39: EXIF data is now stored base64-encoded in the database to prevent issues with raw characters coming off some cameras. EXIF data is no longer replaced on analysis - allowing rotated images to maintain the data. --- app/Http/Controllers/Gallery/PhotoController.php | 4 +++- app/Services/PhotoService.php | 7 ++++++- .../2017_09_15_141905_add_photo_exif_data_column.php | 2 +- resources/lang/en/navigation.php | 1 + resources/views/themes/base/admin/album_metadata.blade.php | 7 ++++--- resources/views/themes/base/gallery/photo_exif.blade.php | 5 +++-- 6 files changed, 18 insertions(+), 8 deletions(-) diff --git a/app/Http/Controllers/Gallery/PhotoController.php b/app/Http/Controllers/Gallery/PhotoController.php index 5379c0d..708fbd2 100644 --- a/app/Http/Controllers/Gallery/PhotoController.php +++ b/app/Http/Controllers/Gallery/PhotoController.php @@ -149,9 +149,11 @@ class PhotoController extends Controller $photo = PhotoController::loadPhotoByAlbumAndFilename($album, $photoFilename); $this->authorizeForUser($this->getUser(), 'changeMetadata', $photo); + $exifData = print_r(unserialize(base64_decode($photo->raw_exif_data)), true); + return Theme::render('gallery.photo_exif', [ 'album' => $album, - 'exif_data' => print_r(unserialize($photo->raw_exif_data), true), + 'exif_data' => $exifData, 'photo' => $photo ]); } diff --git a/app/Services/PhotoService.php b/app/Services/PhotoService.php index 1d515c9..af069e8 100644 --- a/app/Services/PhotoService.php +++ b/app/Services/PhotoService.php @@ -70,7 +70,12 @@ class PhotoService // Read the Exif data $exifData = @exif_read_data($photoFile); $isExifDataFound = ($exifData !== false && is_array($exifData)); - $this->photo->raw_exif_data = $isExifDataFound ? serialize($exifData) : ''; + + if (is_null($this->photo->raw_exif_data)) + { + $this->photo->raw_exif_data = $isExifDataFound ? base64_encode(serialize($exifData)) : ''; + } + $angleToRotate = 0; // If Exif data contains an Orientation, ensure we rotate the original image as such diff --git a/database/migrations/2017_09_15_141905_add_photo_exif_data_column.php b/database/migrations/2017_09_15_141905_add_photo_exif_data_column.php index 812b112..3595818 100644 --- a/database/migrations/2017_09_15_141905_add_photo_exif_data_column.php +++ b/database/migrations/2017_09_15_141905_add_photo_exif_data_column.php @@ -15,7 +15,7 @@ class AddPhotoExifDataColumn extends Migration { Schema::table('photos', function (Blueprint $table) { - $table->longText('raw_exif_data'); + $table->longText('raw_exif_data')->nullable(true); }); } diff --git a/resources/lang/en/navigation.php b/resources/lang/en/navigation.php index cebb7e8..e26e188 100644 --- a/resources/lang/en/navigation.php +++ b/resources/lang/en/navigation.php @@ -16,6 +16,7 @@ return [ 'edit_group' => 'Edit group', 'edit_storage' => 'Edit storage location', 'edit_user' => 'Edit user', + 'exif_data' => 'Exif Data', 'groups' => 'Groups', 'home' => 'Gallery', 'labels' => 'Labels', diff --git a/resources/views/themes/base/admin/album_metadata.blade.php b/resources/views/themes/base/admin/album_metadata.blade.php index 1a9a5a3..075a7d3 100644 --- a/resources/views/themes/base/admin/album_metadata.blade.php +++ b/resources/views/themes/base/admin/album_metadata.blade.php @@ -23,7 +23,7 @@
{{ csrf_field() }} @lang('forms.cancel_action') - +
@@ -36,8 +36,9 @@ @push('scripts') diff --git a/resources/views/themes/base/gallery/photo_exif.blade.php b/resources/views/themes/base/gallery/photo_exif.blade.php index 0274ab6..6a2954c 100644 --- a/resources/views/themes/base/gallery/photo_exif.blade.php +++ b/resources/views/themes/base/gallery/photo_exif.blade.php @@ -6,7 +6,8 @@ @foreach ($album->albumParentTree() as $parentAlbum) @endforeach - + + @endsection @section('content') @@ -24,7 +25,7 @@

-
{{ $exif_data }}
+
{!! $exif_data !!}