Actualmente estoy escribiendo un sistema que almacena metadatos de alrededor de 140,000 imágenes ish almacenadas dentro de una biblioteca de imágenes heredadas que se trasladan al almacenamiento en la nube. Estoy utilizando el siguiente para obtener los datos jpg ...Cómo obtener el tamaño de archivo de "System.Drawing.Image"
System.Drawing.Image image = System.Drawing.Image.FromFile("filePath");
Im bastante nuevo para la manipulación de imágenes, pero esto está muy bien para conseguir los valores simples como anchura, altura, relación de aspecto, etc, pero lo que no puedo hacer ejercicio es cómo para recuperar el tamaño del archivo físico del jpg expresado en bytes. Cualquier ayuda sería muy apreciada.
Gracias
solución final incluyendo un hash MD5 de la imagen para su posterior comparación
System.Drawing.Image image = System.Drawing.Image.FromFile(filePath);
if (image != null)
{
int width = image.Width;
int height = image.Height;
decimal aspectRatio = width > height ? decimal.divide(width, height) : decimal.divide(height, width);
int fileSize = (int)new System.IO.FileInfo(filePath).Length;
using (System.IO.MemoryStream stream = new System.IO.MemoryStream(fileSize))
{
image.Save(stream, System.Drawing.Imaging.ImageFormat.Jpeg);
Byte[] imageBytes = stream.GetBuffer();
System.Security.Cryptography.MD5CryptoServiceProvider provider = new System.Security.Cryptography.MD5CryptoServiceProvider();
Byte[] hash = provider.ComputeHash(imageBytes);
System.Text.StringBuilder hashBuilder = new System.Text.StringBuilder();
for (int i = 0; i < hash.Length; i++)
{
hashBuilder.Append(hash[i].ToString("X2"));
}
string md5 = hashBuilder.ToString();
}
image.Dispose();
}