{"id":340,"date":"2011-12-08T21:17:57","date_gmt":"2011-12-08T11:17:57","guid":{"rendered":"http:\/\/www.reenadu.com\/?p=340"},"modified":"2011-12-08T21:17:57","modified_gmt":"2011-12-08T11:17:57","slug":"resize-photo-in-c","status":"publish","type":"post","link":"https:\/\/nickdu.com\/?p=340","title":{"rendered":"Resize photo in C#"},"content":{"rendered":"<p>Today, my friend asked me to recommend a free resize photo tool, and he got lots of photos. I really don&#8217;t know. Normally I use MS Paint and select Stretch and Skew. If here are many photos, it would take ages. I then wrote a small tool for him using C#. The code is fairly simple cause .Net Framework provides huge library to use.<\/p>\n<pre lang=\"CSharp\">private void ResizePhoto()\n{\n\t\/\/find all jpg photos in given folder\n\tstring[] jpgFiles = Directory.GetFiles(photoPath,\"*.jpg\");\n\tforeach(string file in jpgFiles)\n\t{\n\t\t\/\/load orignial photo into memory\n\t\tImage image = Image.FromFile(file);\n\t\t\/\/create new photo using new size from original photo\n\t\tImage newImage = new Bitmap(image,new Size(newWidth,newHeight));\n\t\t\/\/give a new file name\n\t\tstring newFileName = \"newsize\" + file;\n\t\t\/\/save new photo\n\t\tnewImage.Save(newFileName,System.Drawing.Imaging.ImageFormat.Jpeg);\n\t\tnewImage.Dispose();\n\t\timage.Dispose();\n\t}\n}<\/pre>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Today, my friend asked me to recommend a free resize photo tool, and he got lots of photos. I really don&#8217;t know. Normally I use MS Paint and select Stretch and Skew. If here are many photos, it would take ages. I then wrote a small tool for him using C#. The code is fairly &hellip; <a href=\"https:\/\/nickdu.com\/?p=340\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Resize photo in C#&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9,2],"tags":[],"class_list":["post-340","post","type-post","status-publish","format-standard","hentry","category-net","category-it"],"_links":{"self":[{"href":"https:\/\/nickdu.com\/index.php?rest_route=\/wp\/v2\/posts\/340","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/nickdu.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/nickdu.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/nickdu.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/nickdu.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=340"}],"version-history":[{"count":0,"href":"https:\/\/nickdu.com\/index.php?rest_route=\/wp\/v2\/posts\/340\/revisions"}],"wp:attachment":[{"href":"https:\/\/nickdu.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=340"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/nickdu.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=340"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/nickdu.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=340"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}