Skip to content

Commit

Permalink
nuget updates + tweaks (#141)
Browse files Browse the repository at this point in the history
Co-authored-by: Azure DevOps CI <[email protected]>
  • Loading branch information
f2calv and Azure DevOps CI authored Mar 30, 2023
1 parent cfbdacd commit 525a126
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 22 deletions.
4 changes: 2 additions & 2 deletions samples/GenericHost/GenericHost.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="13.0.2" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="Microsoft.Extensions.Configuration" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="7.0.1" />
<PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="7.0.0" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="CasCap.Common.Testing" Version="2.0.3" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.4.1" />
<PackageReference Include="CasCap.Common.Testing" Version="2.0.7" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.5.0" />
<PackageReference Include="Microsoft.Extensions.Configuration" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="7.0.0" />
<PackageReference Include="SixLabors.ImageSharp" Version="2.1.3" />
<PackageReference Include="SixLabors.ImageSharp" Version="3.0.1" />
<PackageReference Include="xunit" Version="2.4.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">
<PrivateAssets>all</PrivateAssets>
Expand Down
23 changes: 10 additions & 13 deletions src/CasCap.Apis.GooglePhotos.Tests/Tests/ExifTests.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using CasCap.Models;
using CasCap.Services;
using CasCap.Xunit;
using SixLabors.ImageSharp;
using SixLabors.ImageSharp.Metadata.Profiles.Exif;
using System.Diagnostics;
using Xunit;
Expand All @@ -28,7 +27,7 @@ public async Task CheckExifData(string fileName, double latitude, double longitu
var loginResult = await _googlePhotosSvc.LoginAsync();
Assert.True(loginResult);

var tplOriginal = await GetExifInfo(path);
var tplOriginal = await ExifTests.GetExifInfo(path);
Assert.Equal(latitude, tplOriginal.latitude);
Assert.Equal(longitude, tplOriginal.longitude);
Assert.Equal(exifTagCount, tplOriginal.exifTagCount);
Expand All @@ -49,25 +48,25 @@ public async Task CheckExifData(string fileName, double latitude, double longitu

var bytesNoExif = await _googlePhotosSvc.DownloadBytes(uploadedMediaItem, includeExifMetadata: false);
Assert.NotNull(bytesNoExif);
var tplNoExif = await GetExifInfo(bytesNoExif);
var tplNoExif = await ExifTests.GetExifInfo(bytesNoExif);
Assert.True(googleExifTagCount == tplNoExif.exifTagCount);

var bytesWithExif = await _googlePhotosSvc.DownloadBytes(uploadedMediaItem, includeExifMetadata: true);
Assert.NotNull(bytesWithExif);
var tplWithExif = await GetExifInfo(bytesWithExif);
var tplWithExif = await ExifTests.GetExifInfo(bytesWithExif);
Assert.Null(tplWithExif.latitude);//location exif data always stripped :(
Assert.Null(tplWithExif.longitude);//location exif data always stripped :(
Assert.True(tplOriginal.exifTagCount > tplWithExif.exifTagCount);//due to Google-stripping fewer exif tags are returned
Assert.True(googleExifTagCount < tplWithExif.exifTagCount);
}

async Task<(double? latitude, double? longitude, int exifTagCount)> GetExifInfo(string path)
static async Task<(double? latitude, double? longitude, int exifTagCount)> GetExifInfo(string path)
{
using var image = await Image.LoadAsync(path);
return GetLatLong(image);
}

async Task<(double? latitude, double? longitude, int exifTagCount)> GetExifInfo(byte[] bytes)
static async Task<(double? latitude, double? longitude, int exifTagCount)> GetExifInfo(byte[] bytes)
{
var stream = new MemoryStream(bytes);
using var image = await Image.LoadAsync(stream);
Expand All @@ -77,20 +76,18 @@ public async Task CheckExifData(string fileName, double latitude, double longitu
static (double? latitude, double? longitude, int exifTagCount) GetLatLong(Image image)
{
double? latitude = null, longitude = null;
var exifTagCount = image.Metadata.ExifProfile?.Values.Count() ?? 0;
var exifTagCount = image.Metadata.ExifProfile?.Values.Count ?? 0;
if (image.Metadata.ExifProfile.Values?.Any() ?? false)
{
var exifData = image.Metadata.ExifProfile;
if (exifData != null)
{
var gpsLatitude = exifData.GetValue(ExifTag.GPSLatitude);
var gpsLatitudeRef = exifData.GetValue(ExifTag.GPSLatitudeRef);
if (gpsLatitude is not null && gpsLatitudeRef is not null)
if (exifData.TryGetValue(ExifTag.GPSLatitude, out var gpsLatitude)
&& exifData.TryGetValue(ExifTag.GPSLatitudeRef, out var gpsLatitudeRef))
latitude = GetCoordinates(gpsLatitudeRef.ToString(), gpsLatitude.Value);

var gpsLong = exifData.GetValue(ExifTag.GPSLongitude);
var gpsLongRef = exifData.GetValue(ExifTag.GPSLongitudeRef);
if (gpsLong is not null && gpsLongRef is not null)
if (exifData.TryGetValue(ExifTag.GPSLongitude, out var gpsLong)
&& exifData.TryGetValue(ExifTag.GPSLongitudeRef, out var gpsLongRef))
longitude = GetCoordinates(gpsLongRef.ToString(), gpsLong.Value);

Debug.WriteLine($"latitude,longitude = {latitude},{longitude}");
Expand Down
6 changes: 3 additions & 3 deletions src/CasCap.Apis.GooglePhotos/CasCap.Apis.GooglePhotos.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Google.Apis.Auth" Version="1.58.0" />
<PackageReference Include="Google.Apis.Auth" Version="1.60.0" />
<PackageReference Include="Microsoft.AspNetCore.WebUtilities" Version="2.2.0" />
<PackageReference Include="CasCap.Common.Net" Version="2.0.3" />
<PackageReference Include="CasCap.Common.Net" Version="2.0.7" />
<PackageReference Include="MimeTypeMapOfficial" Version="1.0.17" />
<PackageReference Include="Microsoft.Extensions.Http.Polly" Version="7.0.1" />
<PackageReference Include="Microsoft.Extensions.Http.Polly" Version="7.0.4" />
<PackageReference Include="System.Linq.Async" Version="6.0.1" />
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ HttpClient client
public async Task<Album?> GetOrCreateAlbumAsync(string title, StringComparison comparisonType = StringComparison.OrdinalIgnoreCase)
{
var album = await GetAlbumByTitleAsync(title, comparisonType);
if (album is null) album = await CreateAlbumAsync(title);
album ??= await CreateAlbumAsync(title);
return album;
}

Expand Down

0 comments on commit 525a126

Please sign in to comment.