控制台应用程序,用于验证文件夹中图像的DPI [英] Console application for verifying the DPI of images in a folder

查看:70
本文介绍了控制台应用程序,用于验证文件夹中图像的DPI的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个包含许多图像的文件夹,我需要验证图像的DPI(是否为300)。如果它不是300,那么它应该将其转换为300 DPI。使用C#.net我必须这样做。任何人都可以给我一个解决方案

I have a folder having many images , where i need to verify the DPI of the images (wether 300 or not) . if its not 300, then it should convert it to 300 DPI. Using C# .net i have to do this. Can any one give me a solution

推荐答案

请看我对这个问题的评论。如果您确实需要,请阅读:

http ://msdn.microsoft.com/en-us/library/system.drawing.image.horizo​​ntalresolution.aspx [ ^ ],

http://msdn.microsoft.com/en-us/library/system.drawing.image.verticalresolution.aspx [< a href =http://msdn.microsoft.com/en-us/library/system.drawing.image.verticalresolution.aspxtarget =_ blanktitle =New Window> ^ ],

http://msdn.microsoft.com/en -us / library / system.drawing.bitmap.setresolution.aspx [ ^ ]。



-SA
Please see my comment to the question. If you really need it, please read:
http://msdn.microsoft.com/en-us/library/system.drawing.image.horizontalresolution.aspx[^],
http://msdn.microsoft.com/en-us/library/system.drawing.image.verticalresolution.aspx[^],
http://msdn.microsoft.com/en-us/library/system.drawing.bitmap.setresolution.aspx[^].

—SA


将图像加载到System.Drawing.Image中。 Horizo​​ntalResolution和VerticalResolution字段为您提供DPI,因此您需要检查它们是否为300.



如果DPI不是300,您需要更清楚该怎么做你可以将它设置为300,这可能会导致整体'显示尺寸'发生变化,或者你可以调整它以预先设置尺寸,但最后可能会插入像素。


如果它只是第一个,我会看看我怀疑能够做到的SetPropertyItem,但我从未尝试过......
Load your image into a System.Drawing.Image. The fields HorizontalResolution and VerticalResolution give you DPI, so you need to check they are both 300.

You need to be clearer about what to do if the DPI is not 300. You could just set it to 300 which may cause the overall 'display size' to change, or you could resize it to preseve the size but then you might end up interpolating the pixels.

If it's just the first, I'd look at SetPropertyItem which I suspect will be able to do it, but I've never tried...


非常感谢guyz为你的回复。
Thanks a lot guyz for your replies.


这篇关于控制台应用程序,用于验证文件夹中图像的DPI的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆