Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Apr 07, 2012 12:03 PM by Trolderik
Apr 07, 2012 10:06 AM|LINK
I've got a peace of code, but i know it consumes more resources than i'd like to make it automatic and on the fly, so could anyone please help me come up with an idea to create a parser to parse the files in a directoryinfo for their respective width and
void ParseDirectory(string path)
DirectoryInfo di = new DirectoryInfo(path);
foreach (FileInfo fi in di.GetFiles("*.jpg", SearchOption.TopDiretoryOnly))
System.Drawing.Image img = System.Drawing.Image.FromFile(fi.FullName);
if(img.Width > 900)
I've also got a bit of code to resize the image, i'm going to post it, but as this doesn't run every single time, it doesn't have to be that strictly on the resource usage, it's only ment as a secondary if anyone knows of something.
void resizeImage(System.Drawing.Image img,string filename)
System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(900,600);
System.Drawing.Graphics graphics = System.Drawing.Graphics.FromImage(bmp);
// some options, removed because they fill a lot of space
Apr 07, 2012 11:24 AM|LINK
You can get image Height and Width without loading the image.
Getting image height and width from its header is explained in following articles.
For resizing images in fastest way refer this article
Also refer this thread to get some alternative methods enlisted.
Hope it helps.
Apr 07, 2012 12:03 PM|LINK
Thank you very much, those links where usefull beyond what i hoped for!