Browse Source

Fix Pillow issue with recognizing pngs

pull/333/head
Ionite 1 year ago
parent
commit
28a593d420
No known key found for this signature in database
  1. 12
      StabilityMatrix.Avalonia/ViewModels/Base/InferenceGenerationViewModelBase.cs

12
StabilityMatrix.Avalonia/ViewModels/Base/InferenceGenerationViewModelBase.cs

@ -205,11 +205,23 @@ public abstract partial class InferenceGenerationViewModelBase
uploadName uploadName
); );
// For pngs, strip metadata since Pillow can't handle some valid files?
if (localFile.Info.Extension.Equals(".png", StringComparison.OrdinalIgnoreCase))
{
var bytes = PngDataHelper.RemoveMetadata(await localFile.ReadAllBytesAsync());
using var stream = new MemoryStream(bytes);
await client.UploadImageAsync(stream, uploadName);
}
else
{
await using var stream = localFile.Info.OpenRead(); await using var stream = localFile.Info.OpenRead();
await client.UploadImageAsync(stream, uploadName); await client.UploadImageAsync(stream, uploadName);
} }
} }
} }
}
/// <summary> /// <summary>
/// Runs a generation task /// Runs a generation task

Loading…
Cancel
Save