![]() When it finds them it automatically creates thumbnails, and web sized versions. My personal website uses a simple directory scanner to look for new collections of images. I have a number of programs I have written that end up doing image resizing and minor image manipulation. Multiplier = ( float)MaxHeight / ( float)Height if we can't get our max width, then use the max height Multiplier = ( float)(( float)MaxWidth / ( float)Width) check to see if we can shrink it width first this means you want to shrink // an image that is already shrunken! if (Height <= MaxHeight & Width <= MaxWidth) / passing by ref so fast /// public static Size GetDimensions( int MaxWidth, / /// max width of the new image /// max height of the new image /// BMP of the current image, / then max dimensions it will not resize it. / /// this function aims to give you a best fit GetDimensions(MaxWidth, MaxHeight, ref OriginalBmp) īitmap NewBmp = new Bitmap(OriginalBmp, ResizedDimensions) load up the image, figure out a "best fit" // resize, and then save that new image / /// Max width of the new image /// Max Height of the new image /// Original file name /// new file name public static void ResizeImage( int MaxWidth, int MaxHeight, / /// This function takes a max width/height ResizeImage( 600, 600, FileName, NewFileName) string NewFileName = FileName.Substring( 0, quickly slap "_resized.jpg" at the end. when you use send to it will pass each file // as it's own string in args foreach ( string FileName in args) We can easily iterate through each of the files. When a file is selected and the “send to” command is used, each filename is passed in as a subsequent command line parameter. On my computer (Windows 2003), the directory is located at \Documents and Settings\User\SendTo. In order to register a program to be used in “Send to”, you need to add a shortcut to the Send to directory. (References -> Add Reference -> System.drawing | OK). If you want to create a console application from scratch, you need to manually add a “.NET reference” to System.Drawing. ![]() Reading and understanding this article should hopefully be very easy, and greatly expand your programming options. It also touches on how to do basic console program operations like read/write to console and pass in parameters. I use a more robust version of this embedded into my website to automatically resize images for gallery collections. This program gives a very quick introduction on how to take an image and resize it. Quick Snip is accessed via the "Send to" menu and drops a JPG in the same directory with the name + "_resized.jpg". Common image software like GIMP and Photoshop have too much overhead - opening, picking settings and choosing directories over and over again is annoying. I often want to take pictures with a digital camera and just want a 600 max width picture that I can easily email to my friends. Quick Snip is an incredibly lightweight application to make "web sized" pictures out of large images.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |