ice framework documentation ice doc v1.6.2
Methods
  • getFile() : void
  • getWidth() : void
  • getHeight() : void
  • getType() : void
  • getMime() : void
  • factory(string $file, string $driver) : void
    Loads an image and prepares it for manipulation.
  • __construct(string $file) : void
    Loads information about the image. Will throw an exception if the image does not exist or is not an image.
  • __toString() : string
    Render the current image.
  • resize(int $width, int $height, int $master) : Ice\Image
    Resize the image to the given size. Either the width or the height can be omitted and the image will be resized proportionally.
  • crop(int $width, int $height, variable $offsetX, variable $offsetY) : Ice\Image
    Crop an image to the given size. Either the width or the height can be omitted and the current width or height will be used.
  • rotate(int $degrees) : Ice\Image
    Rotate the image by a given amount.
  • flip(int $direction) : Ice\Image
    Flip the image along the horizontal or vertical axis.
  • sharpen(int $amount) : Ice\Image
    Sharpen the image by a given amount.
  • reflection(int $height, int $opacity, bool $fadeIn) : Ice\Image
    Add a reflection to an image. The most opaque part of the reflection will be equal to the opacity setting and fade out to full transparent.
  • watermark(variable $watermark, int $offsetX, int $offsetY, int $opacity) : Ice\Image
    Add a watermark to an image with a specified opacity. Alpha transparency will be preserved.
  • background(string $color, int $opacity) : Ice\Image
    Set the background color of an image. This is only useful for images with alpha transparency.
  • save(string $file, int $quality) : bool
    Save the image. If the filename is omitted, the original image will be overwritten.
  • render(string $type, int $quality) : string
    Render the image and return the binary string.
  • doResize(int $width, int $height) : void
    Execute a resize.
  • doCrop(int $width, int $height, int $offset_x, int $offset_y) : void
    Execute a crop.
  • doRotate(int $degrees) : void
    Execute a rotation.
  • doFlip(int $direction) : void
    Execute a flip.
  • doSharpen(int $amount) : void
    Execute a sharpen.
  • doReflection(int $height, int $opacity, bool $fadeIn) : void
    Execute a reflection.
  • doWatermark(variable $image, int $offsetX, int $offsetY, int $opacity) : void
    Execute a watermarking.
  • doBackground(int $r, int $g, int $b, int $opacity) : void
    Execute a background.
  • doSave(string $file, int $quality) : bool
    Execute a save.
  • doRender(string $type, int $quality) : string
    Execute a render.
Methods Details
  • public function getFile()

  • public function getWidth()

  • public function getHeight()

  • public function getType()

  • public function getMime()

  • public static function factory(string $file, string $driver)

    Loads an image and prepares it for manipulation.
    
          $image = new Image('upload/test.jpg');
         
  • public function __construct(string $file)

    Loads information about the image. Will throw an exception if the image does not exist or is not an image.
  • public function __toString()

    Render the current image.
    
          echo $image;
         
  • public function resize(int $width, int $height, int $master)

    Resize the image to the given size. Either the width or the height can be omitted and the image will be resized proportionally.
    
          // Resize to 200 pixels on the shortest side
          $image->resize(200, 200);
         
          // Resize to 200x200 pixels, keeping aspect ratio
          $image->resize(200, 200, Image::INVERSE);
         
          // Resize to 500 pixel width, keeping aspect ratio
          $image->resize(500, null);
         
          // Resize to 500 pixel height, keeping aspect ratio
          $image->resize(null, 500);
         
          // Resize to 200x500 pixels, ignoring aspect ratio
          $image->resize(200, 500, Image::NONE);
         
  • public function crop(int $width, int $height, variable $offsetX, variable $offsetY)

    Crop an image to the given size. Either the width or the height can be omitted and the current width or height will be used.
    If no offset is specified, the center of the axis will be used. If an offset of true is specified, the bottom of the axis will be used.
    
          // Crop the image to 200x200 pixels, from the center
          $image->crop(200, 200);
         
  • public function rotate(int $degrees)

    Rotate the image by a given amount.
    
          // Rotate 45 degrees clockwise
          $image->rotate(45);
         
          // Rotate 90% counter-clockwise
          $image->rotate(-90);
         
  • public function flip(int $direction)

    Flip the image along the horizontal or vertical axis.
    
          // Flip the image from top to bottom
          $image->flip(Image::HORIZONTAL);
         
          // Flip the image from left to right
          $image->flip(Image::VERTICAL);
         
  • public function sharpen(int $amount)

    Sharpen the image by a given amount.
    
          // Sharpen the image by 20%
          $image->sharpen(20);
         
  • public function reflection(int $height, int $opacity, bool $fadeIn)

    Add a reflection to an image. The most opaque part of the reflection will be equal to the opacity setting and fade out to full transparent.
    Alpha transparency is preserved.
    
          // Create a 50 pixel reflection that fades from 0-100% opacity
          $image->reflection(50);
         
          // Create a 50 pixel reflection that fades from 100-0% opacity
          $image->reflection(50, 100, true);
         
          // Create a 50 pixel reflection that fades from 0-60% opacity
          $image->reflection(50, 60, true);
         
    [!!] By default, the reflection will be go from transparent at the top to opaque at the bottom.
  • public function watermark(variable $watermark, int $offsetX, int $offsetY, int $opacity)

    Add a watermark to an image with a specified opacity. Alpha transparency will be preserved.
    If no offset is specified, the center of the axis will be used. If an offset of true is specified, the bottom of the axis will be used.
    
          // Add a watermark to the bottom right of the image
          $mark = new Image('upload/watermark.png');
          $image->watermark($mark, true, true);
         
  • public function background(string $color, int $opacity)

    Set the background color of an image. This is only useful for images with alpha transparency.
    
          // Make the image background black
          $image->background('#000');
         
          // Make the image background black with 50% opacity
          $image->background('#000', 50);
         
  • public function save(string $file, int $quality)

    Save the image. If the filename is omitted, the original image will be overwritten.
    
          // Save the image as a PNG
          $image->save('saved/cool.png');
         
          // Overwrite the original image
          $image->save();
         
    [!!] If the file exists, but is not writable, an exception will be thrown. [!!] If the file does not exist, and the directory is not writable, an exception will be thrown.
  • public function render(string $type, int $quality)

    Render the image and return the binary string.
    
          // Render the image at 50% quality
          $data = image->render(null, 50);
         
          // Render the image as a PNG
          $data = image->render('png');
         
  • abstract protected function doResize(int $width, int $height)

    Execute a resize.
  • abstract protected function doCrop(int $width, int $height, int $offset_x, int $offset_y)

    Execute a crop.
  • abstract protected function doRotate(int $degrees)

    Execute a rotation.
  • abstract protected function doFlip(int $direction)

    Execute a flip.
  • abstract protected function doSharpen(int $amount)

    Execute a sharpen.
  • abstract protected function doReflection(int $height, int $opacity, bool $fadeIn)

    Execute a reflection.
  • abstract protected function doWatermark(variable $image, int $offsetX, int $offsetY, int $opacity)

    Execute a watermarking.
  • abstract protected function doBackground(int $r, int $g, int $b, int $opacity)

    Execute a background.
  • abstract protected function doSave(string $file, int $quality)

    Execute a save.
  • abstract protected function doRender(string $type, int $quality)

    Execute a render.