Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>The code needs to not only pay attention to the current ratio, but how you're changing the ratio with the crop.</p> <p>Also, the height calculation was based on half the desired height, and should have been the full height.</p> <p>Assuming all else is correct with your code, you should be able to place the code below into your FileExists if block, replacing the current content.</p> <pre><code>&lt;cfset CurrentWidth = imageDataThumb.width&gt; &lt;cfset CurrentHeight = imageDataThumb.height&gt; &lt;cfset CurrentRatio = CurrentWidth / CurrentHeight&gt; &lt;cfset DesiredRatio = 68 / 46&gt; &lt;cfif CurrentWidth GTE CurrentHeight&gt; &lt;!--- Landscape Image ---&gt; &lt;cfif CurrentRatio LT DesiredRatio&gt; &lt;!--- More Landscape ---&gt; &lt;cfset Keep = "width"&gt; &lt;cfelse&gt; &lt;!--- Less Landscape ---&gt; &lt;cfset Keep = "height"&gt; &lt;/cfif&gt; &lt;cfelse&gt; &lt;!--- Portrait Image ---&gt; &lt;cfif CurrentRatio GT DesiredRatio&gt; &lt;!--- More Portrait ---&gt; &lt;cfset Keep = "height"&gt; &lt;cfelse&gt; &lt;!--- Less Portrait ---&gt; &lt;cfset Keep = "width"&gt; &lt;/cfif&gt; &lt;/cfif&gt; &lt;cfif Keep EQ "width"&gt; &lt;!--- Crop top/bottom edges of images ---&gt; &lt;cfset ImageResize(cfImageThumb,"68","")&gt; &lt;cfset ImageCrop(cfImageThumb,0,(cfImageThumb.height-46)/2,68,46)&gt; &lt;cfelse&gt; &lt;!--- Crop left/right edges of images ---&gt; &lt;cfset ImageResize(cfImageThumb,"","46")&gt; &lt;cfset ImageCrop(cfImageThumb,(cfImageThumb.width-68)/2,0,68,46)&gt; &lt;/cfif&gt; &lt;cfimage source="#cfImageThumb#" action="write" destination="images/gallery/thumbs/thm_#imageMed[i].medium.XmlText#" overwrite="yes"&gt; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload