<?xml version="1.0" encoding="utf-8" ?><rss version="2.0" xml:base="https://www.webmaster-forums.net/crss/node/1041257" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title></title>
    <link>https://www.webmaster-forums.net/crss/node/1041257</link>
    <description></description>
    <language>en</language>
          <item>
    <title>Yeah, I forgot to throw out</title>
    <link>https://www.webmaster-forums.net/web-programming-and-application-development/aspect-ratio-logic#comment-1230513</link>
    <description> &lt;p&gt;Yeah, I forgot to throw out that while() loop.  I&#039;d finish off with something like this.&lt;br /&gt;
&lt;div class=&quot;codeblock&quot;&gt;&lt;code&gt;&lt;span style=&quot;color: #000000&quot;&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;&amp;lt;?php&lt;br /&gt;$imagesize &lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;= &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;getimagesize&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;&quot;&quot;&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;); &lt;/span&gt;&lt;span style=&quot;color: #FF8000&quot;&gt;//Path to image&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$image_width &lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;= &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$imagesize&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;]; &lt;/span&gt;&lt;span style=&quot;color: #FF8000&quot;&gt;//Width of image&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$image_height &lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;= &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$imagesize&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;]; &lt;/span&gt;&lt;span style=&quot;color: #FF8000&quot;&gt;//Height of image&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$max_width &lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;= &lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;&quot;&quot;&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;; &lt;/span&gt;&lt;span style=&quot;color: #FF8000&quot;&gt;//These two need to be defined.&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$max_height &lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;= &lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;&quot;&quot;&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;;&lt;br /&gt;&amp;nbsp; if (&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$image_width &lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;&amp;gt; &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$image_height&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;) {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #FF8000&quot;&gt;/*Now find the proportion of width to height and use it to determine the new height.&amp;nbsp; The new width will be the max width.*/&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$prop &lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;= (&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$image_width &lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;/ &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$image_height&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$image_width &lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;= &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$max_width&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$image_height &lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;= &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;round&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$max_height &lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;/ &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$prop&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;);&lt;br /&gt;&amp;nbsp; }&lt;br /&gt;&amp;nbsp; elseif (&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$image_height &lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;&amp;gt; &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$image_width&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;) {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$prop &lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;= (&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$image_height &lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;/ &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$image_width&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$image_height &lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;= &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$max_height&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$image_width &lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;= &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;round&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$max_width &lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;/ &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$prop&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;);&lt;br /&gt;&amp;nbsp; }&lt;br /&gt;&amp;nbsp; else {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$image_width &lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;= &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$max_width&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$image_height &lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;= &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$max_height&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;;&lt;br /&gt;&amp;nbsp; }&lt;br /&gt;echo &lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;&quot;&amp;lt;img src=\&quot;\&quot; width=\&quot;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$image_width&lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;\&quot; height=\&quot;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$image_height&lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;\&quot; /&amp;gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;?&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/div&gt;&lt;/p&gt;
 </description>
     <pubDate>Sat, 07 Jun 2008 18:40:54 +0000</pubDate>
 <dc:creator>mscreashuns</dc:creator>
 <guid isPermaLink="false">comment 1230513 at https://www.webmaster-forums.net</guid>
  </item>
  <item>
    <title>You are awesome. Thanks for</title>
    <link>https://www.webmaster-forums.net/web-programming-and-application-development/aspect-ratio-logic#comment-1230493</link>
    <description> &lt;p&gt;You are awesome. Thanks for the code mscreashuns! That works perfectly. &lt;/p&gt;
&lt;p&gt;There is no need for a loop because your code gets the height and width assigned a value within the bounds in one pass. The only reason I put a loop there was because I thought I would have to make multiple passes and keep subtracting until the size was in bounds. (I return earlier in the code if the image is already small enough).&lt;/p&gt;
&lt;p&gt;Thanks!&lt;/p&gt;
 </description>
     <pubDate>Sat, 07 Jun 2008 05:41:12 +0000</pubDate>
 <dc:creator>teammatt3</dc:creator>
 <guid isPermaLink="false">comment 1230493 at https://www.webmaster-forums.net</guid>
  </item>
  <item>
    <title>Are the max width and max</title>
    <link>https://www.webmaster-forums.net/web-programming-and-application-development/aspect-ratio-logic#comment-1230491</link>
    <description> &lt;p&gt;Are the max width and max height variables defined globally (for all images) or individually?  I guess the only problem I&#039;m having is deciding is if there&#039;s a way you would know beforehand if the width or height was larger.  If not, you could run a test to find out and do something different in each case.  I&#039;m working on a code right now, and I&#039;ll post it when I&#039;m finished, but I wanted to see if that might set you off in the right direction. &lt;img src=&quot;https://www.webmaster-forums.net/misc/smileys/wink.png&quot; title=&quot;Wink&quot; alt=&quot;Wink&quot; class=&quot;smiley-content&quot; /&gt;&lt;/p&gt;
&lt;p&gt;Edit:  Alright, here&#039;s what I got.  I checked it on rectangular and square images alike, and the following complete code works.  Obviously you can cut out some parts of it and rework the getimagesize() function to suit multiple images.&lt;br /&gt;
&lt;div class=&quot;codeblock&quot;&gt;&lt;code&gt;&lt;span style=&quot;color: #000000&quot;&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;&amp;lt;?php&lt;br /&gt;$imagesize &lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;= &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;getimagesize&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;&quot;&quot;&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;); &lt;/span&gt;&lt;span style=&quot;color: #FF8000&quot;&gt;//Path to image&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$image_width &lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;= &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$imagesize&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;]; &lt;/span&gt;&lt;span style=&quot;color: #FF8000&quot;&gt;//Width of image&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$image_height &lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;= &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$imagesize&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;]; &lt;/span&gt;&lt;span style=&quot;color: #FF8000&quot;&gt;//Height of image&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$max_width &lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;= &lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;&quot;&quot;&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;; &lt;/span&gt;&lt;span style=&quot;color: #FF8000&quot;&gt;//These two need to be defined.&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$max_height &lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;= &lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;&quot;&quot;&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;;&lt;br /&gt;while((&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$image_width &lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;&amp;gt; &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$max_width&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;) || (&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$image_height &lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;&amp;gt; &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$max_height&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;)) {&lt;br /&gt;&amp;nbsp; if (&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$image_width &lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;&amp;gt; &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$image_height&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;) {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #FF8000&quot;&gt;/*Now find the proportion of width to height and use it to determine the new height.&amp;nbsp; The new width will be the max width.*/&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$prop &lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;= (&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$image_width &lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;/ &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$image_height&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$image_width &lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;= &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$max_width&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$image_height &lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;= &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;round&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$max_height &lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;/ &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$prop&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;);&lt;br /&gt;&amp;nbsp; }&lt;br /&gt;&amp;nbsp; else {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$prop &lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;= (&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$image_height &lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;/ &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$image_width&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$image_height &lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;= &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$max_height&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$image_width &lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;= &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;round&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$max_width &lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;/ &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$prop&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;);&lt;br /&gt;&amp;nbsp; }&lt;br /&gt;}&lt;br /&gt;echo &lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;&quot;&amp;lt;img src=\&quot;\&quot; width=\&quot;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$image_width&lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;\&quot; height=\&quot;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$image_height&lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;\&quot; /&amp;gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;?&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/div&gt;&lt;/p&gt;
 </description>
     <pubDate>Sat, 07 Jun 2008 03:05:45 +0000</pubDate>
 <dc:creator>mscreashuns</dc:creator>
 <guid isPermaLink="false">comment 1230491 at https://www.webmaster-forums.net</guid>
  </item>
  </channel>
</rss>
