From f2a7965101311bb876a0ff1f8a81790b202341ce Mon Sep 17 00:00:00 2001 From: Bond_009 Date: Tue, 11 Dec 2018 14:55:33 +0100 Subject: [PATCH] Replace TagLib.Portable.dll with taglib-sharp submodule --- .gitmodules | 3 + Emby.Photos/Emby.Photos.csproj | 4 +- Emby.Photos/PhotoProvider.cs | 167 ++++++++++++++++----------------- 3 files changed, 86 insertions(+), 88 deletions(-) create mode 100644 .gitmodules diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000000..2ef569c7cd --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "ThirdParty/taglib-sharp"] + path = ThirdParty/taglib-sharp + url = git@github.com:mono/taglib-sharp.git diff --git a/Emby.Photos/Emby.Photos.csproj b/Emby.Photos/Emby.Photos.csproj index f16ce6b9c9..f8c2156a62 100644 --- a/Emby.Photos/Emby.Photos.csproj +++ b/Emby.Photos/Emby.Photos.csproj @@ -3,9 +3,7 @@ - - ..\ThirdParty\taglib\TagLib.Portable.dll - + diff --git a/Emby.Photos/PhotoProvider.cs b/Emby.Photos/PhotoProvider.cs index f1a05607f8..3e998997a7 100644 --- a/Emby.Photos/PhotoProvider.cs +++ b/Emby.Photos/PhotoProvider.cs @@ -57,118 +57,115 @@ namespace Emby.Photos { try { - using (var fileStream = _fileSystem.OpenRead(item.Path)) + using (var file = TagLib.File.Create(item.Path)) { - using (var file = TagLib.File.Create(new StreamFileAbstraction(Path.GetFileName(item.Path), fileStream, null))) + var image = file as TagLib.Image.File; + + var tag = file.GetTag(TagTypes.TiffIFD) as IFDTag; + + if (tag != null) { - var image = file as TagLib.Image.File; + var structure = tag.Structure; - var tag = file.GetTag(TagTypes.TiffIFD) as IFDTag; - - if (tag != null) + if (structure != null) { - var structure = tag.Structure; + var exif = structure.GetEntry(0, (ushort)IFDEntryTag.ExifIFD) as SubIFDEntry; - if (structure != null) + if (exif != null) { - var exif = structure.GetEntry(0, (ushort)IFDEntryTag.ExifIFD) as SubIFDEntry; + var exifStructure = exif.Structure; - if (exif != null) + if (exifStructure != null) { - var exifStructure = exif.Structure; + var entry = exifStructure.GetEntry(0, (ushort)ExifEntryTag.ApertureValue) as RationalIFDEntry; - if (exifStructure != null) + if (entry != null) { - var entry = exifStructure.GetEntry(0, (ushort)ExifEntryTag.ApertureValue) as RationalIFDEntry; + double val = entry.Value.Numerator; + val /= entry.Value.Denominator; + item.Aperture = val; + } - if (entry != null) - { - double val = entry.Value.Numerator; - val /= entry.Value.Denominator; - item.Aperture = val; - } + entry = exifStructure.GetEntry(0, (ushort)ExifEntryTag.ShutterSpeedValue) as RationalIFDEntry; - entry = exifStructure.GetEntry(0, (ushort)ExifEntryTag.ShutterSpeedValue) as RationalIFDEntry; - - if (entry != null) - { - double val = entry.Value.Numerator; - val /= entry.Value.Denominator; - item.ShutterSpeed = val; - } + if (entry != null) + { + double val = entry.Value.Numerator; + val /= entry.Value.Denominator; + item.ShutterSpeed = val; } } } } + } - if (image != null) + if (image != null) + { + item.CameraMake = image.ImageTag.Make; + item.CameraModel = image.ImageTag.Model; + + item.Width = image.Properties.PhotoWidth; + item.Height = image.Properties.PhotoHeight; + + var rating = image.ImageTag.Rating; + if (rating.HasValue) { - item.CameraMake = image.ImageTag.Make; - item.CameraModel = image.ImageTag.Model; + item.CommunityRating = rating; + } + else + { + item.CommunityRating = null; + } - item.Width = image.Properties.PhotoWidth; - item.Height = image.Properties.PhotoHeight; + item.Overview = image.ImageTag.Comment; - var rating = image.ImageTag.Rating; - if (rating.HasValue) + if (!string.IsNullOrWhiteSpace(image.ImageTag.Title)) + { + if (!item.LockedFields.Contains(MetadataFields.Name)) { - item.CommunityRating = rating; + item.Name = image.ImageTag.Title; } - else + } + + var dateTaken = image.ImageTag.DateTime; + if (dateTaken.HasValue) + { + item.DateCreated = dateTaken.Value; + item.PremiereDate = dateTaken.Value; + item.ProductionYear = dateTaken.Value.Year; + } + + item.Genres = image.ImageTag.Genres; + item.Tags = image.ImageTag.Keywords; + item.Software = image.ImageTag.Software; + + if (image.ImageTag.Orientation == TagLib.Image.ImageOrientation.None) + { + item.Orientation = null; + } + else + { + MediaBrowser.Model.Drawing.ImageOrientation orientation; + if (Enum.TryParse(image.ImageTag.Orientation.ToString(), true, out orientation)) { - item.CommunityRating = null; + item.Orientation = orientation; } + } - item.Overview = image.ImageTag.Comment; + item.ExposureTime = image.ImageTag.ExposureTime; + item.FocalLength = image.ImageTag.FocalLength; - if (!string.IsNullOrWhiteSpace(image.ImageTag.Title)) - { - if (!item.LockedFields.Contains(MetadataFields.Name)) - { - item.Name = image.ImageTag.Title; - } - } + item.Latitude = image.ImageTag.Latitude; + item.Longitude = image.ImageTag.Longitude; + item.Altitude = image.ImageTag.Altitude; - var dateTaken = image.ImageTag.DateTime; - if (dateTaken.HasValue) - { - item.DateCreated = dateTaken.Value; - item.PremiereDate = dateTaken.Value; - item.ProductionYear = dateTaken.Value.Year; - } - - item.Genres = image.ImageTag.Genres; - item.Tags = image.ImageTag.Keywords; - item.Software = image.ImageTag.Software; - - if (image.ImageTag.Orientation == TagLib.Image.ImageOrientation.None) - { - item.Orientation = null; - } - else - { - MediaBrowser.Model.Drawing.ImageOrientation orientation; - if (Enum.TryParse(image.ImageTag.Orientation.ToString(), true, out orientation)) - { - item.Orientation = orientation; - } - } - - item.ExposureTime = image.ImageTag.ExposureTime; - item.FocalLength = image.ImageTag.FocalLength; - - item.Latitude = image.ImageTag.Latitude; - item.Longitude = image.ImageTag.Longitude; - item.Altitude = image.ImageTag.Altitude; - - if (image.ImageTag.ISOSpeedRatings.HasValue) - { - item.IsoSpeedRating = Convert.ToInt32(image.ImageTag.ISOSpeedRatings.Value); - } - else - { - item.IsoSpeedRating = null; - } + if (image.ImageTag.ISOSpeedRatings.HasValue) + { + item.IsoSpeedRating = Convert.ToInt32(image.ImageTag.ISOSpeedRatings.Value); + } + else + { + item.IsoSpeedRating = null; } } }