You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I want to translate the following code into Python, but I found that SKFilter Quality is not available High
But I found that there is no 【SKFilterQuality.High】
public static async Task<string> GetAverageHash(Stream input)
{
MemoryStream memoryStream = new MemoryStream();
await input.CopyToAsync(memoryStream);
var imageBytes =memoryStream.ToArray();
using (var imageStream = new SKMemoryStream(imageBytes))
using (var original = SKBitmap.Decode(imageStream))
{
using (var resized = original.Resize(new SKImageInfo(30, 30), SKFilterQuality.High))
{
int total = 0;
for (int y = 0; y < resized.Height; y++)
{
for (int x = 0; x < resized.Width; x++)
{
var pixel = resized.GetPixel(x, y);
int gray = (int)(pixel.Red * 0.3 + pixel.Green * 0.59 + pixel.Blue * 0.11);
total += gray;
}
}
int average = total / (resized.Width * resized.Height);
string hash = "";
for (int y = 0; y < resized.Height; y++)
{
for (int x = 0; x < resized.Width; x++)
{
var pixel = resized.GetPixel(x, y);
hash += pixel.Red > average ? "1" : "0";
}
}
return GetMd5Hash(hash)+ "|" + imageBytes.Length;
}
}
}
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I want to translate the following code into Python, but I found that SKFilter Quality is not available High
But I found that there is no 【SKFilterQuality.High】
Beta Was this translation helpful? Give feedback.
All reactions