I want to check out whe开发者_开发技巧ther the photograph is suitable for print or not using my application.How can I do that?I don't know much about photo quality?Is the resolution of every photograph is same or not?
I think the only factor in print quality that you can check with any certainty (because the other factors are subjective), is the resolution of the image vs. the intended print size. If you have other tangible requirements, like the image must be color, not black and white, you can check for that too. But trying to identify whether an image is too blurry, low contrast, etc., will likely be a fruitless pursuit, as you never know whether the image was intended to be that way or not.
A common rule of thumb is that you should have at least 240 dots per inch when printing, and 300 is even better. Of course with quality printers, higher resolution than that can yield better results, and if you are printing very high detail, like fine text, you may want to go to 600dpi and above.
So to print an 8" x 10" image using the minimum figure of 240 dpi, you would want an image that is at least 1920 x 2400 pixels (a total of 4,608,000 pixels, or about 4.5 megapixels).
If you decide you want at least 300dpi when printing an 8" x 10", then you want an image with at least 2400 x 3000 pixels, which is about 7 megapixels.
Stepping up to 600dpi? You'll need about a 28 megapixel image in that case.
Example:
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();
}
}
}
There are a great many factors that will differentiate an image that is "of good quality" and "of bad quality"
wikipedia has a short list of those factors
Most of these are rather hard to check for programatically and involve complex imaging algorithms. Checking for resolution is easy however, if it is the only criteria between a good and a bad image.
This simple code tells you how to do it
I think the most basic code to get resolution is this
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);
精彩评论