<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -1,3 +1,4 @@
+= smart_resize_image
 Should be easy to find, right? All you want is a function that resizes an image to constraints (doesn't care if it should scale up or down), with possibility to select if you want to keep it proportional, and possibility to use either width or height as the constraint. Also, you want it to preserve transparency damn it! Surprisingly, I was unable to find a good function that does all that, so I decided to attempt writing it. This should do it.
 
 == Features/Usage:</diff>
      <filename>README.rdoc</filename>
    </modified>
    <modified>
      <diff>@@ -1,8 +1,13 @@
 &lt;?
-  function smart_resize_image( $file, $width = 0, $height = 0, $proportional = false, $output = 'file', $delete_original = true, $use_linux_commands = false ) {
-    if ( $height &lt;= 0 &amp;&amp; $width &lt;= 0 ) {
-      return false;
-    }
+  function smart_resize_image($file,
+                              $width              = 0, 
+                              $height             = 0, 
+                              $proportional       = false, 
+                              $output             = 'file', 
+                              $delete_original    = true, 
+                              $use_linux_commands = false ) {
+      
+    if ( $height &lt;= 0 &amp;&amp; $width &lt;= 0 ) return false;
 
     # Setting defaults and meta
     $info                         = getimagesize($file);
@@ -13,9 +18,9 @@
 
     # Calculating proportionality
     if ($proportional) {
-      if ($width == 0)      $factor = $height/$height_old;
-      elseif ($height == 0) $factor = $width/$width_old;
-      else                  $factor = min( $width / $width_old, $height / $height_old );
+      if      ($width  == 0)  $factor = $height/$height_old;
+      elseif  ($height == 0)  $factor = $width/$width_old;
+      else                    $factor = min( $width / $width_old, $height / $height_old );
 
       $final_width  = round( $width_old * $factor );
       $final_height = round( $height_old * $factor );
@@ -56,10 +61,8 @@
     
     # Taking care of original, if needed
     if ( $delete_original ) {
-      if ( $use_linux_commands )
-        exec('rm '.$file);
-      else
-        @unlink($file);
+      if ( $use_linux_commands ) exec('rm '.$file);
+      else @unlink($file);
     }
 
     # Preparing a method of providing result</diff>
      <filename>smart_resize_image.function.php</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>0837abf9fd14dcbb64aa4a0dc4d80fbbd29de87c</id>
    </parent>
  </parents>
  <author>
    <name>Maxim Chernyak</name>
    <email>max@bitsonnet.com</email>
  </author>
  <url>http://github.com/maxim/smart_resize_image/commit/8f2c53651bae87178d7e13dc85e23bb22a990bae</url>
  <id>8f2c53651bae87178d7e13dc85e23bb22a990bae</id>
  <committed-date>2009-01-29T00:29:48-08:00</committed-date>
  <authored-date>2009-01-29T00:29:48-08:00</authored-date>
  <message>Add formatting enhancements.</message>
  <tree>5848c425bf22a9aad1af6716712a9f11e26ef46e</tree>
  <committer>
    <name>Maxim Chernyak</name>
    <email>max@bitsonnet.com</email>
  </committer>
</commit>
