pastebin - collaborative debugging

pastebin is a collaborative debugging tool allowing you to share and modify code snippets while chatting on IRC, IM or a message board.

This site is developed to XHTML and CSS2 W3C standards. If you see this paragraph, your browser does not support those standards and you need to upgrade. Visit WaSP for a variety of options.

kohana private pastebin - collaborative debugging tool What's a private pastebin?


Posted by MinusCreative on Wed 30 Apr 05:28
report abuse | download | new post

  1. /*
  2.  * The canvas master dimension will cause
  3.  * your image to be resized without the borders
  4.  * of the resulting image breaking into the
  5.  * dimensions you specify in the resize:
  6.  *
  7.  * i.e. if you specify resize(500, 20, Image::CANVAS)
  8.  * your image the resulting image may end up 500x350
  9.  * or if it's a tall image, it could be 500x2000.
  10.  * The point is; it will never be smaller on any side
  11.  * than the minimum dimension you specify. This is
  12.  * useful if you want to crop an image, using the
  13.  * maximum amount of image possible independent of
  14.  * its input or output aspect ratio and dimensions.
  15.  */
  16.  
  17. if ($properties['master'] === Image::CANVAS)
  18. {
  19.         $tmp_image_ar = $width / $height;
  20.         $canvas_ar = $properties['width'] / $properties['height'];
  21.  
  22.         if ($canvas_ar >= 1)
  23.         {
  24.                 if ($tmp_image_ar >= 1)
  25.                 { // wide
  26.                         // wide enough
  27.                         if (($width*$canvas_ar) >= $height)
  28.                         {
  29.                                 $properties['master'] = Image::HEIGHT;
  30.                                 $properties['height'] = $properties['height'];
  31.                                 $properties['width'] = round($properties['height'] * $tmp_image_ar);
  32.                         }
  33.                         // not wide enough for our ar; it would break into the box
  34.                         else
  35.                         {
  36.                                 $properties['master'] = Image::WIDTH;
  37.                                 $properties['width'] = $properties['width'];
  38.                                 $properties['height'] = round($properties['width'] * $tmp_image_ar);
  39.                         }
  40.                 }
  41.                 else
  42.                 { // tall
  43.                         // tall enough
  44.                         if ($width >= ($height * $canvas_ar))
  45.                         {
  46.                                 $properties['master'] = Image::HEIGHT;
  47.                                 $properties['height'] = $properties['height'];
  48.                                 $properties['width'] = round($properties['height'] / $tmp_image_ar);
  49.                         }
  50.                         // not tall enough for our ar; it would break into the box
  51.                         else
  52.                         {
  53.                                 $properties['master'] = Image::WIDTH;
  54.                                 $properties['width'] = $properties['width'];
  55.                                 $properties['height'] = round($properties['width'] / $tmp_image_ar);
  56.                         }
  57.                 }
  58.         }
  59.         else
  60.         {
  61.                 if ($tmp_image_ar >= 1)
  62.                 { // wide
  63.                         // wide enough
  64.                         if (($height * $canvas_ar) >= $width)
  65.                         {
  66.                                 $properties['master'] = Image::WIDTH;
  67.                                 $properties['width'] = $properties['width'];
  68.                                 $properties['height'] = round($properties['width'] * $tmp_image_ar);
  69.                         }
  70.                         // not wide enough for our ar; it would break into the box
  71.                         else
  72.                         {
  73.                                 $properties['master'] = Image::HEIGHT;
  74.                                 $properties['height'] = $properties['height'];
  75.                                 $properties['width'] = round($properties['height'] * $tmp_image_ar);
  76.                         }
  77.                 }
  78.                 else
  79.                 { // tall
  80.                         // tall enough
  81.                         if ($height >= ($width * $canvas_ar))
  82.                         {
  83.                                 $properties['master'] = Image::WIDTH;
  84.                                 $properties['width'] = $properties['width'];
  85.                                 $properties['height'] = round($properties['width'] / $tmp_image_ar);
  86.                         }
  87.                         // not tall enough for our ar; it would break into the box
  88.                         else
  89.                         {
  90.                                 $properties['master'] = Image::HEIGHT;
  91.                                 $properties['height'] = $properties['height'];
  92.                                 $properties['width'] = round($properties['height'] / $tmp_image_ar);
  93.                         }
  94.                 }
  95.         }
  96. }

Submit a correction or amendment below (click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.

Syntax highlighting:

To highlight particular lines, prefix each line with @@


Remember me