<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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/"
		>
<channel>
	<title>Comments on: How to Resize Image Proportionally using JavaScript</title>
	<atom:link href="http://www.ajaxblender.com/howto-resize-image-proportionally-using-javascript.html/feed" rel="self" type="application/rss+xml" />
	<link>http://www.ajaxblender.com/howto-resize-image-proportionally-using-javascript.html</link>
	<description>A Whole Lot of AJAX!</description>
	<lastBuildDate>Tue, 10 Jan 2012 16:11:09 -0500</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.5</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: educer</title>
		<link>http://www.ajaxblender.com/howto-resize-image-proportionally-using-javascript.html/comment-page-1#comment-2275</link>
		<dc:creator>educer</dc:creator>
		<pubDate>Thu, 15 Sep 2011 18:10:56 +0000</pubDate>
		<guid isPermaLink="false">http://www.ajaxblender.com/?p=1023#comment-2275</guid>
		<description>Thanks for the article and the comments, they were very useful ;)
This works with jQuery:

$(document).ready(function(){
var img = $(&quot;#image-landscape&quot;);
var initW = img.width();
var initH = img.height();

$(&#039;.controls LI A&#039;).each(function(i, el){
$(el).click(function(e){
var newW = img.width(), newH = 0;
switch(el.rel){
case &#039;zoomOut&#039;:
newW -= 100;
break;
case &#039;zoomIn&#039;:
newW += 100;
break;
case &#039;resizeProportionally&#039;:
var newSize = scaleSize(200, 200, $(el.rev).width(), $(el.rev).height());
$(el.rev).width = newSize[0];
$(el.rev).height = newSize[1];
alert(&#039;New Width: &#039; + newSize[0] + &#039;, New Height: &#039; + newSize[1]);
return;
default:
newW = initW;            
}

var ratio = initH / initW;
newH = newW * ratio;

img.attr(&#039;width&#039;, newW);
img.attr(&#039;height&#039;, newH);
});
});
});</description>
		<content:encoded><![CDATA[<p>Thanks for the article and the comments, they were very useful ;)<br />
This works with jQuery:</p>
<p>$(document).ready(function(){<br />
var img = $(&#8221;#image-landscape&#8221;);<br />
var initW = img.width();<br />
var initH = img.height();</p>
<p>$(&#8217;.controls LI A&#8217;).each(function(i, el){<br />
$(el).click(function(e){<br />
var newW = img.width(), newH = 0;<br />
switch(el.rel){<br />
case &#8216;zoomOut&#8217;:<br />
newW -= 100;<br />
break;<br />
case &#8216;zoomIn&#8217;:<br />
newW += 100;<br />
break;<br />
case &#8216;resizeProportionally&#8217;:<br />
var newSize = scaleSize(200, 200, $(el.rev).width(), $(el.rev).height());<br />
$(el.rev).width = newSize[0];<br />
$(el.rev).height = newSize[1];<br />
alert(&#8217;New Width: &#8216; + newSize[0] + &#8216;, New Height: &#8216; + newSize[1]);<br />
return;<br />
default:<br />
newW = initW;<br />
}</p>
<p>var ratio = initH / initW;<br />
newH = newW * ratio;</p>
<p>img.attr(&#8217;width&#8217;, newW);<br />
img.attr(&#8217;height&#8217;, newH);<br />
});<br />
});<br />
});</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: ajaxBlender.com</title>
		<link>http://www.ajaxblender.com/howto-resize-image-proportionally-using-javascript.html/comment-page-1#comment-2078</link>
		<dc:creator>ajaxBlender.com</dc:creator>
		<pubDate>Wed, 31 Aug 2011 06:56:35 +0000</pubDate>
		<guid isPermaLink="false">http://www.ajaxblender.com/?p=1023#comment-2078</guid>
		<description>Hello Websoftwares.
In your code you have array of images commented, that&#039;s why it&#039;s not working.</description>
		<content:encoded><![CDATA[<p>Hello Websoftwares.<br />
In your code you have array of images commented, that&#8217;s why it&#8217;s not working.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Websoftwares</title>
		<link>http://www.ajaxblender.com/howto-resize-image-proportionally-using-javascript.html/comment-page-1#comment-2013</link>
		<dc:creator>Websoftwares</dc:creator>
		<pubDate>Thu, 25 Aug 2011 16:51:42 +0000</pubDate>
		<guid isPermaLink="false">http://www.ajaxblender.com/?p=1023#comment-2013</guid>
		<description>@mark i came up with this it works but on my content sometimes getSize().x or y shows 0.

Anyone can help on that, thanks.

window.addEvent(&#039;domready&#039;,function(){
	if(document.getElement(&#039;div.blog_description&#039;)) {
		// only run on selected elements else don&#039;t.
		var images = document.getElement(&#039;div.blog_description&#039;).getElements(&#039;img&#039;);
//get all images	     Array.each(images,function(image,index) {
         // loop over all images.		 	
		 var newSize = scaleSize(200, 200, image.getSize().x, image.getSize().y);
		 // run function to get new sizes
		 image.width = newSize[0];
		 // set new width 
		 image.height = newSize[1] 
		 // set new height	   
		})          
	}
});</description>
		<content:encoded><![CDATA[<p>@mark i came up with this it works but on my content sometimes getSize().x or y shows 0.</p>
<p>Anyone can help on that, thanks.</p>
<p>window.addEvent(&#8217;domready&#8217;,function(){<br />
	if(document.getElement(&#8217;div.blog_description&#8217;)) {<br />
		// only run on selected elements else don&#8217;t.<br />
		var images = document.getElement(&#8217;div.blog_description&#8217;).getElements(&#8217;img&#8217;);<br />
//get all images	     Array.each(images,function(image,index) {<br />
         // loop over all images.<br />
		 var newSize = scaleSize(200, 200, image.getSize().x, image.getSize().y);<br />
		 // run function to get new sizes<br />
		 image.width = newSize[0];<br />
		 // set new width<br />
		 image.height = newSize[1]<br />
		 // set new height<br />
		})<br />
	}<br />
});</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mark</title>
		<link>http://www.ajaxblender.com/howto-resize-image-proportionally-using-javascript.html/comment-page-1#comment-1697</link>
		<dc:creator>Mark</dc:creator>
		<pubDate>Wed, 20 Jul 2011 21:16:05 +0000</pubDate>
		<guid isPermaLink="false">http://www.ajaxblender.com/?p=1023#comment-1697</guid>
		<description>Could you provide a simple example showing your script resizing multiple images automatically to any image using a particular class name?</description>
		<content:encoded><![CDATA[<p>Could you provide a simple example showing your script resizing multiple images automatically to any image using a particular class name?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Noob</title>
		<link>http://www.ajaxblender.com/howto-resize-image-proportionally-using-javascript.html/comment-page-1#comment-1191</link>
		<dc:creator>Noob</dc:creator>
		<pubDate>Thu, 05 May 2011 11:11:47 +0000</pubDate>
		<guid isPermaLink="false">http://www.ajaxblender.com/?p=1023#comment-1191</guid>
		<description>Thanks for a great post, and thanks emidio your solution is what made the scaling work for really large images!</description>
		<content:encoded><![CDATA[<p>Thanks for a great post, and thanks emidio your solution is what made the scaling work for really large images!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: emidio</title>
		<link>http://www.ajaxblender.com/howto-resize-image-proportionally-using-javascript.html/comment-page-1#comment-1071</link>
		<dc:creator>emidio</dc:creator>
		<pubDate>Wed, 13 Apr 2011 10:59:06 +0000</pubDate>
		<guid isPermaLink="false">http://www.ajaxblender.com/?p=1023#comment-1071</guid>
		<description>&quot;} else if(currH &gt;= maxH){&quot;

change in:
&quot;} if(currH &gt;= maxH){&quot;
else the function do the resize only one side (width or height) if the image is greater then both width and height</description>
		<content:encoded><![CDATA[<p>&#8220;} else if(currH &gt;= maxH){&#8221;</p>
<p>change in:<br />
&#8220;} if(currH &gt;= maxH){&#8221;<br />
else the function do the resize only one side (width or height) if the image is greater then both width and height</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: John hook</title>
		<link>http://www.ajaxblender.com/howto-resize-image-proportionally-using-javascript.html/comment-page-1#comment-1068</link>
		<dc:creator>John hook</dc:creator>
		<pubDate>Tue, 12 Apr 2011 23:34:35 +0000</pubDate>
		<guid isPermaLink="false">http://www.ajaxblender.com/?p=1023#comment-1068</guid>
		<description>hey I&#039;m trying to put this code on the blogger for my blog put I can&#039;t save it because it gives me always an error I&#039;ve put on the top this code.



var newSize = scaleSize(200, 200, 500, 313);
alert(&#039;New Width: &#039; + newSize[0] + &#039;, New Height: &#039; + newSize[1]);

function scaleSize(maxW, maxH, currW, currH){

var ratio = currH / currW;

if(currW &gt;= maxW &amp;&amp; ratio if(currH &gt;= maxH){
currH = maxH;
currW = currH / ratio;
}

return [currW, currH];
}


is this right or not? 

thanks in advance!</description>
		<content:encoded><![CDATA[<p>hey I&#8217;m trying to put this code on the blogger for my blog put I can&#8217;t save it because it gives me always an error I&#8217;ve put on the top this code.</p>
<p>var newSize = scaleSize(200, 200, 500, 313);<br />
alert(&#8217;New Width: &#8216; + newSize[0] + &#8216;, New Height: &#8216; + newSize[1]);</p>
<p>function scaleSize(maxW, maxH, currW, currH){</p>
<p>var ratio = currH / currW;</p>
<p>if(currW &gt;= maxW &amp;&amp; ratio if(currH &gt;= maxH){<br />
currH = maxH;<br />
currW = currH / ratio;<br />
}</p>
<p>return [currW, currH];<br />
}</p>
<p>is this right or not? </p>
<p>thanks in advance!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: rudrax</title>
		<link>http://www.ajaxblender.com/howto-resize-image-proportionally-using-javascript.html/comment-page-1#comment-1051</link>
		<dc:creator>rudrax</dc:creator>
		<pubDate>Mon, 04 Apr 2011 03:40:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.ajaxblender.com/?p=1023#comment-1051</guid>
		<description>hay, its great!thanks Alex.</description>
		<content:encoded><![CDATA[<p>hay, its great!thanks Alex.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tapestry</title>
		<link>http://www.ajaxblender.com/howto-resize-image-proportionally-using-javascript.html/comment-page-1#comment-923</link>
		<dc:creator>Tapestry</dc:creator>
		<pubDate>Fri, 28 Jan 2011 14:16:35 +0000</pubDate>
		<guid isPermaLink="false">http://www.ajaxblender.com/?p=1023#comment-923</guid>
		<description>This looks close to what I am looking for.  I need to resize an image width: 507px height: 370px, keeping it centered, depending on the clients resolution.  The image needs to scale down depending upon the screen size.  Is this possible?  Thank you in advance for your help.</description>
		<content:encoded><![CDATA[<p>This looks close to what I am looking for.  I need to resize an image width: 507px height: 370px, keeping it centered, depending on the clients resolution.  The image needs to scale down depending upon the screen size.  Is this possible?  Thank you in advance for your help.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: ajaxBlender.com</title>
		<link>http://www.ajaxblender.com/howto-resize-image-proportionally-using-javascript.html/comment-page-1#comment-674</link>
		<dc:creator>ajaxBlender.com</dc:creator>
		<pubDate>Thu, 15 Jul 2010 16:36:29 +0000</pubDate>
		<guid isPermaLink="false">http://www.ajaxblender.com/?p=1023#comment-674</guid>
		<description>Jeff,

In jQuery, you should process it differently. For example:

&lt;code&gt;$(&#039;.controls LI A&#039;).click(function(){
     alert(&#039;Link has been clicked.&#039;);
     return false;
});&lt;/code&gt;

Try it and let me know if it is okay.

Thanks,

Alex</description>
		<content:encoded><![CDATA[<p>Jeff,</p>
<p>In jQuery, you should process it differently. For example:</p>
<p><code>$('.controls LI A').click(function(){<br />
     alert('Link has been clicked.');<br />
     return false;<br />
});</code></p>
<p>Try it and let me know if it is okay.</p>
<p>Thanks,</p>
<p>Alex</p>
]]></content:encoded>
	</item>
</channel>
</rss>

