Calculate the original area of the current image int Area = width * height / /// The original image width /// The original image height /// A generic list of Double /// private List CalculateDimensionsByArea( int width, / the calculated area of the new image (a percentage of the original image area). / and width for the resized image based upon / /// Performs a calculation to resolve the new height It actually took me a few hours to figure this one out, so I'm quite proud of myself. This was actually a bit of a mathematical puzzle, and I'd never seen imaging software do this, so Google was no help. Instead of just simply halving the width and the height of the image if I want to reduce it by 50%, what about if I made it to take up half the area? Now, all this is a bit high-brow and outside the scope of this article, but after following the instructions in the comments, I was able to convert the code into fully safe code, and added a few enhancements like Floyd Steinburg dithering.Īs a bit of a challenge, I set myself the task of resizing the images in a different way. To improve upon the results, I did a bit of Googling, and stumbled upon the Octree Quantizer. Resizing images is fairly easy with GDI+, but sometimes the results leave a lot to be desired, especially when editing GIF files. " Batch Completed", MessageBoxButtons.OK, MessageBox.Show( " All queued images processed", private void bwResize_RunWorkerCompleted( object sender, / The /// instance containing the event data. / /// Handles the RunWorkerCompleted event of the bwResize control. Windows7Tools.SetTaskbarProgressValue(e.ProgressPercentage) private void bwResize_ProgressChanged( object sender, ProgressChangedEventArgs e) / The // instance containing the event data. / /// Handles the ProgressChanged event of the bwResize control. private void bwResize_DoWork( Object sender, DoWorkEventArgs e) / /// Handles the DoWork event of the bwResize control. The vast majority of the work is handled by a background worker with three simple routines to give the user a smoother interface experience. There are a few more settings for painting matte background onto transparent GIFs and for using different diffusion techniques for reducing colours, but the default should work nicely. Simply load up a folder full of images, choose a destination folder, choose your reduction ratio, and click Go. The Empirical Design Batch Image Resizer. I wanted to be able to resize transparent GIFs and indexed PNG files, so I started work on something of my own that I could then share with the public. I liked what he had done, but I thought his software didn't quite cut it. I looked around for alternatives, and stumbled across the Image Batch Resizer by Alberto Venditti. As a web developer, I have the luxury of doing this using Photoshop, but not everyone has access to that. People like to share those images, but more often than not, the various networking services restrict the file size, so users have to resize the images first before they can upload them. Thanks z33z.Īlmost everyone has a digital camera these days, and nearly as many people have some sort of social networking account. Output images now preserve EXIF information.Added the ability to set a height/width for the output (automatically ignores images smaller than definitions and preserves aspect ratio).Added the ability to check subfolders. They were all good ideas so here they are below. I've made quite a few changes to the program to cater for the feature requests here on CodeProject. This article describes a program designed to resize large numbers of images in a single batch process, and how that program was enhanced using some of the new Windows 7 features.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |