dispose stream in PhotoProvider
This commit is contained in:
parent
992ad9c2d9
commit
00507972be
|
@ -35,110 +35,113 @@ namespace Emby.Photos
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
using (var file = TagLib.File.Create(new StreamFileAbstraction(Path.GetFileName(item.Path), _fileSystem.OpenRead(item.Path), null)))
|
using (var fileStream = _fileSystem.OpenRead(item.Path))
|
||||||
{
|
{
|
||||||
var image = file as TagLib.Image.File;
|
using (var file = TagLib.File.Create(new StreamFileAbstraction(Path.GetFileName(item.Path), fileStream, null)))
|
||||||
|
|
||||||
var tag = file.GetTag(TagTypes.TiffIFD) as IFDTag;
|
|
||||||
|
|
||||||
if (tag != null)
|
|
||||||
{
|
{
|
||||||
var structure = tag.Structure;
|
var image = file as TagLib.Image.File;
|
||||||
|
|
||||||
if (structure != null)
|
var tag = file.GetTag(TagTypes.TiffIFD) as IFDTag;
|
||||||
|
|
||||||
|
if (tag != null)
|
||||||
{
|
{
|
||||||
var exif = structure.GetEntry(0, (ushort)IFDEntryTag.ExifIFD) as SubIFDEntry;
|
var structure = tag.Structure;
|
||||||
|
|
||||||
if (exif != null)
|
if (structure != null)
|
||||||
{
|
{
|
||||||
var exifStructure = exif.Structure;
|
var exif = structure.GetEntry(0, (ushort)IFDEntryTag.ExifIFD) as SubIFDEntry;
|
||||||
|
|
||||||
if (exifStructure != null)
|
if (exif != null)
|
||||||
{
|
{
|
||||||
var entry = exifStructure.GetEntry(0, (ushort)ExifEntryTag.ApertureValue) as RationalIFDEntry;
|
var exifStructure = exif.Structure;
|
||||||
|
|
||||||
if (entry != null)
|
if (exifStructure != null)
|
||||||
{
|
{
|
||||||
double val = entry.Value.Numerator;
|
var entry = exifStructure.GetEntry(0, (ushort)ExifEntryTag.ApertureValue) as RationalIFDEntry;
|
||||||
val /= entry.Value.Denominator;
|
|
||||||
item.Aperture = val;
|
|
||||||
}
|
|
||||||
|
|
||||||
entry = exifStructure.GetEntry(0, (ushort)ExifEntryTag.ShutterSpeedValue) as RationalIFDEntry;
|
if (entry != null)
|
||||||
|
{
|
||||||
|
double val = entry.Value.Numerator;
|
||||||
|
val /= entry.Value.Denominator;
|
||||||
|
item.Aperture = val;
|
||||||
|
}
|
||||||
|
|
||||||
if (entry != null)
|
entry = exifStructure.GetEntry(0, (ushort)ExifEntryTag.ShutterSpeedValue) as RationalIFDEntry;
|
||||||
{
|
|
||||||
double val = entry.Value.Numerator;
|
if (entry != null)
|
||||||
val /= entry.Value.Denominator;
|
{
|
||||||
item.ShutterSpeed = val;
|
double val = entry.Value.Numerator;
|
||||||
|
val /= entry.Value.Denominator;
|
||||||
|
item.ShutterSpeed = val;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
item.CameraMake = image.ImageTag.Make;
|
item.CameraMake = image.ImageTag.Make;
|
||||||
item.CameraModel = image.ImageTag.Model;
|
item.CameraModel = image.ImageTag.Model;
|
||||||
|
|
||||||
item.Width = image.Properties.PhotoWidth;
|
item.Width = image.Properties.PhotoWidth;
|
||||||
item.Height = image.Properties.PhotoHeight;
|
item.Height = image.Properties.PhotoHeight;
|
||||||
|
|
||||||
var rating = image.ImageTag.Rating;
|
var rating = image.ImageTag.Rating;
|
||||||
if (rating.HasValue)
|
if (rating.HasValue)
|
||||||
{
|
|
||||||
item.CommunityRating = rating;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
item.CommunityRating = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
item.Overview = image.ImageTag.Comment;
|
|
||||||
|
|
||||||
if (!string.IsNullOrWhiteSpace(image.ImageTag.Title))
|
|
||||||
{
|
|
||||||
item.Name = image.ImageTag.Title;
|
|
||||||
}
|
|
||||||
|
|
||||||
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.ToList();
|
|
||||||
item.Tags = image.ImageTag.Keywords.ToList();
|
|
||||||
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.CommunityRating = rating;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
item.CommunityRating = null;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
item.ExposureTime = image.ImageTag.ExposureTime;
|
item.Overview = image.ImageTag.Comment;
|
||||||
item.FocalLength = image.ImageTag.FocalLength;
|
|
||||||
|
|
||||||
item.Latitude = image.ImageTag.Latitude;
|
if (!string.IsNullOrWhiteSpace(image.ImageTag.Title))
|
||||||
item.Longitude = image.ImageTag.Longitude;
|
{
|
||||||
item.Altitude = image.ImageTag.Altitude;
|
item.Name = image.ImageTag.Title;
|
||||||
|
}
|
||||||
|
|
||||||
if (image.ImageTag.ISOSpeedRatings.HasValue)
|
var dateTaken = image.ImageTag.DateTime;
|
||||||
{
|
if (dateTaken.HasValue)
|
||||||
item.IsoSpeedRating = Convert.ToInt32(image.ImageTag.ISOSpeedRatings.Value);
|
{
|
||||||
}
|
item.DateCreated = dateTaken.Value;
|
||||||
else
|
item.PremiereDate = dateTaken.Value;
|
||||||
{
|
item.ProductionYear = dateTaken.Value.Year;
|
||||||
item.IsoSpeedRating = null;
|
}
|
||||||
|
|
||||||
|
item.Genres = image.ImageTag.Genres.ToList();
|
||||||
|
item.Tags = image.ImageTag.Keywords.ToList();
|
||||||
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user