How to check image quality in a program using C #?

I want to check if the photo is suitable for printing or not to use my application. How can i do this? I don’t know much about the quality of the photograph? Is the resolution of each photo the same or not?

+3
source share
2 answers

I think that the only factor of print quality that you can check with any certainty (because other factors are subjective) is the resolution of the image compared to the estimated print size. If you have other tangible requirements, for example, the image should be color, not black and white, you can check it. But, trying to determine if the image is too blurry, low contrast, etc., is likely to be fruitless pursuit, since you never know whether the image was designed that way or not.

, 240 , 300 - . , , , , , 600 .

, 8 "x 10" 240 , 1920 x 2400 ( 4 608 000 4,5 ).

, 300 8 "x 10", 2400 x 3000 , 7 .

600 ? 28- .

:

using System;
using System.Drawing;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            int minimumPrintDpi = 240;
            int targetPrintWidthInches = 8;
            int targetPrintHeightInches = 10;
            int minimumImageWidth = targetPrintWidthInches * minimumPrintDpi;
            int minimumImageHeight = targetPrintHeightInches * minimumPrintDpi;

            var img = Image.FromFile(@"C:\temp\CaptainKangaroo.jpg");

            Console.WriteLine(string.Format("Minimum DPI for printing: {0}", minimumPrintDpi));
            Console.WriteLine(string.Format("Target print size: width:{0}\" x height:{1}\"", targetPrintWidthInches, targetPrintHeightInches));
            Console.WriteLine(string.Format("Minimum image horizontal resolution: {0}", minimumImageWidth));
            Console.WriteLine(string.Format("Minimum image vertical resolution: {0}", minimumImageHeight));
            Console.WriteLine(string.Format("Actual Image horizontal resolution: {0}", img.Width));
            Console.WriteLine(string.Format("Actual Image vertical resolution: {0}", img.Height));
            Console.WriteLine(string.Format("Actual image size in megapixels: {0}", ((float)img.Height * img.Width) / 1000000));
            Console.WriteLine(string.Format("Image resolution sufficient? {0}", img.Width >= minimumImageWidth && img.Height >= minimumImageHeight));
            Console.WriteLine(string.Format("Maximum recommended print size for this image: width:{0}\" x height:{1}\"", (float)img.Width / minimumPrintDpi, (float)img.Height / minimumPrintDpi));

            Console.ReadKey();
        }
    }
}
+3

, " " " "

wikipedia

. , .

,

, -

  Bitmap bmp = new Bitmap("winter.jpg");

  Console.WriteLine("Image resolution: " + bmp.HorizontalResolution + " DPI");
  Console.WriteLine("Image resolution: " + bmp.VerticalResolution + " DPI");
  Console.WriteLine("Image Width: " + bmp.Width);
  Console.WriteLine("Image Height: " + bmp.Height);
0

Source: https://habr.com/ru/post/1738853/


All Articles