<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>prasadsambari</title>
	<atom:link href="http://prasadsambari.abhista.com/wordpress/?feed=rss2" rel="self" type="application/rss+xml" />
	<link>http://prasadsambari.abhista.com/wordpress</link>
	<description></description>
	<lastBuildDate>Thu, 11 Aug 2011 20:09:20 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Resize Any image While Maintaining Aspect Ratio and Maximum width &amp; Height</title>
		<link>http://prasadsambari.abhista.com/wordpress/?p=81</link>
		<comments>http://prasadsambari.abhista.com/wordpress/?p=81#comments</comments>
		<pubDate>Thu, 11 Aug 2011 20:09:20 +0000</pubDate>
		<dc:creator>prasad</dc:creator>
				<category><![CDATA[Jquery]]></category>

		<guid isPermaLink="false">http://prasadsambari.abhista.com/wordpress/?p=81</guid>
		<description><![CDATA[It works well for resizing but changing the aspect ratio of the original image squashes the new image.
Example :
Convert a 150*100 image into a 150*150 image.
The extra 50 pixels of the height need to be padded with a white background color.

public void ResizeImage(string OriginalFile, string NewFile, int NewWidth, int MaxHeight, bool OnlyResizeIfWider)
{
System.Drawing.Image FullsizeImage = System.Drawing.Image.FromFile(OriginalFile);
// [...]]]></description>
			<content:encoded><![CDATA[<p>It works well for resizing but changing the aspect ratio of the original image squashes the new image.</p>
<p><em><strong>Example :</strong></em><br />
Convert a 150*100 image into a 150*150 image.<br />
The extra 50 pixels of the height need to be padded with a white background color.</p>
<h4></h4>
<p>public void ResizeImage(string OriginalFile, string NewFile, int NewWidth, int MaxHeight, bool OnlyResizeIfWider)<br />
{<br />
System.Drawing.Image FullsizeImage = System.Drawing.Image.FromFile(OriginalFile);</p>
<p>// Prevent using images internal thumbnail<br />
FullsizeImage.RotateFlip(System.Drawing.RotateFlipType.Rotate180FlipNone);<br />
FullsizeImage.RotateFlip(System.Drawing.RotateFlipType.Rotate180FlipNone);</p>
<p>if (OnlyResizeIfWider)<br />
{<br />
if (FullsizeImage.Width &lt;= NewWidth)<br />
{<br />
NewWidth = FullsizeImage.Width;<br />
}<br />
}</p>
<p>int NewHeight = FullsizeImage.Height * NewWidth / FullsizeImage.Width;<br />
if (NewHeight &gt; MaxHeight)<br />
{<br />
// Resize with height instead<br />
NewWidth = FullsizeImage.Width * MaxHeight / FullsizeImage.Height;<br />
NewHeight = MaxHeight;<br />
}</p>
<p>System.Drawing.Image NewImage = FullsizeImage.GetThumbnailImage(NewWidth, NewHeight, null, IntPtr.Zero);</p>
<p>// Clear handle to original file so that we can overwrite it if necessary<br />
FullsizeImage.Dispose();</p>
<p>// Save resized picture<br />
NewImage.Save(NewFile);<br />
}</p>
]]></content:encoded>
			<wfw:commentRss>http://prasadsambari.abhista.com/wordpress/?feed=rss2&amp;p=81</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

