public function __construct($height, $backgroundColor = 'ffffff', $startOpacity = 30, $divLineHeight = 1) { $this->height = Args::int($height, 'height')->required()->min(1)->value(); $this->startOpacity = Args::int($startOpacity, 'Start Opacity')->required()->min(0)->max(100)->value(); $this->backgroundColor = $backgroundColor instanceof Color ? $backgroundColor : new Color($backgroundColor); $this->divLineHeight = Args::int($divLineHeight, 'divLineHeight')->required()->min(0)->value(); }
/** * * @param number $aNumberOfBlocks The number of blocks * @param number $aBlockSize The size of the blocks in pixels * @param string $aBlockColor The color of the blocks */ public function __construct($numberOfBlocks = 100, $blockSize = 25, $blockColor = 'FFFFFF') { $this->nrOfBlocks = Args::int($numberOfBlocks)->required()->min(1)->value(); $this->blockSize = Args::int($blockSize)->required()->min(0)->value(); // TODO blockcolor can be Object and string... add check to args $this->blockColor = $blockColor instanceof Color ? $blockColor : new Color($blockColor); }
/** * Generate a gradient image * * @param int $width The new image width in pixels * @param int $height The new image height in pixels * @param int $start The start of the gradient in pixels * @param Color $src_color The start image color * @param Color $dest_color The end image color * * @return \imagemanipulation\ImageResource */ public static function gradient($width, $height, $start, Color $src_color, Color $dest_color) { Args::int($width, 'width')->required()->min(1); Args::int($height, 'height')->required()->min(1); $res = self::create($width, $height, $src_color); $img = $res->getResource(); $srcA = $src_color->getAlpha(); $srcR = $src_color->getRed(); $srcG = $src_color->getGreen(); $srcB = $src_color->getBlue(); $destA = $dest_color->getAlpha(); $destR = $dest_color->getRed(); $destG = $dest_color->getGreen(); $destB = $dest_color->getBlue(); $incA = ($destA - $srcA) / ($width - $start); $incR = ($destR - $srcR) / ($width - $start); $incG = ($destG - $srcG) / ($width - $start); $incB = ($destB - $srcB) / ($width - $start); for ($i = $start; $i < $width; $i++) { $srcA += $incA; $srcB += $incB; $srcG += $incG; $srcR += $incR; imagefilledrectangle($img, $i, 0, $i, $height, imagecolorallocatealpha($img, $srcR, $srcG, $srcB, $srcA)); } return $res; }
/** * Creates a new overlay * * @param ImageResource $aOverlay The overlay to apply * @param number $aOpacity The opacity between 0 and 100 * @param number $startX start X pixel of the overlay * @param number $startY start Y pixel of the overlay * @param boolean $fill Fill the overlay using the height of the original image, or use the size of the overlay */ public function __construct(ImageResource $overlay, $opacity = 50, $startX = 0, $startY = 0, $fill = true) { $this->startX = Args::int($startX, 'startX')->required()->min(0)->value(); $this->startY = Args::int($startY, 'startY')->required()->min(0)->value(); $this->opacity = Args::int($opacity, 'opacity')->required()->min(1)->max(100)->value(); $this->fill = Args::bool($fill, 'fill')->required()->value(); $this->overlay = $overlay; }
public static function createImage($width, $height) { Args::int($width, 'width')->required()->min(0); Args::int($height, 'height')->required()->min(0); $imgRes = imagecreatetruecolor($width, $height); imageantialias($imgRes, true); imagealphablending($imgRes, true); imagesavealpha($imgRes, true); return $imgRes; }
/** * Creates a new ImageFilterRotate * * @param int $aAngle The degrees to rotate the image * @param String $aBgcolor The background color to apply * */ public function __construct($angle = 90, $aBgcolor = null) { $this->angle = Args::int($ange, 'angle')->required()->min(-360)->max(360)->value(function ($val) { return $val < 0 ? 360 - $val : $val; }); if ($aBgcolor === null) { $this->bgColor = ColorFactory::white(); } else { $this->bgColor = $aBgcolor instanceof Color ? $aBgcolor : new Color($aBgcolor); } }
public function __construct($width, $height, $isPercentage = false) { if ($isPercentage) { Args::int($width, 'width')->min(1)->max(100)->required(); Args::int($height, 'height')->min(1)->max(100)->required(); } else { Args::int($width, 'width')->min(1)->required(); Args::int($height, 'height')->min(1)->required(); } $this->width = $width; $this->height = $height; $this->isPercentage = $isPercentage; }
/** * Creates a transparent (PNG, JPG) image with a <code>aWidth</code> and <code>aHeight</code>. * * @param int $aWidth The width of the image * @param int $aHeight The height of the image * @return resource */ public static function createTransparentImage($width, $height) { Args::int($width, 'width')->required()->min(0); Args::int($height, 'height')->required()->min(0); $color = ColorFactory::white(127); $imgRes = imagecreatetruecolor($width, $height); imageantialias($imgRes, true); imagealphablending($imgRes, true); imagesavealpha($imgRes, true); $transparent = self::allocateColor($imgRes, $color); imagefill($imgRes, 0, 0, $transparent); return $imgRes; }
public function __construct($noise = 20) { $this->noise = Args::int($noise)->required()->min(0)->value(); }
/** * Creates a new ImageFilterDuotone * * @param int $red The amount of red to add max = 255 * @param int $green The amount of green to add max = 255 * @param int $bleu The amount of blue to add max = 255 */ public function __construct($red = 0, $green = 0, $blue = 0) { $this->red = Args::int($red)->required()->min(0)->max(255)->value(); $this->green = Args::int($green)->required()->min(0)->max(255)->value(); $this->blue = Args::int($blue)->required()->min(0)->max(255)->value(); }
public function __construct(ImageResource $aResource, $width, $height) { $this->resource = $aResource; $this->width = Args::int($width, 'width')->required()->min(0)->value(); $this->height = Args::int($height, 'height')->required()->min(0)->value(); }
public function __construct($input = 1.0, $output = 1.537) { $this->input = Args::float($input, 'input')->required()->min(0)->value(); $this->output = Args::float($output, 'output')->required()->min(0)->value(); }
/** * Creates a new ImageFilterSepia * * @param int $aDarken */ public function __construct($darken = 15) { $this->opacity = Args::int($darken, 'darken')->required()->min(0)->value(function ($opacity) { return 127 - min(array($opacity + 30, 127)); }); }
public function __construct($percentage = 100) { $this->percentage = Args::int($percentage, 'percentage')->required()->min(0)->max(100)->value(); }
/** * * @param number $aOffset */ public function __construct($degrees = 90) { $this->degrees = Args::int($degrees)->required()->min(0)->value(function ($degrees) { return $degrees > 360 ? $degrees % 360 : $degrees; }); }
/** * Creates a new filter for watermarking an image * * @param \SplFileInfo $aWatermark The full path to a watermark image * @param string $aPosition The position where to place the watermark. Use the POS_* constants * @param string $aWatermarkOpacity [optional] The opacity of the watermark image. */ public function __construct(\SplFileInfo $aWatermark, $aPosition = 'bottom-right', $watermarkOpacity = null) { $this->watermark = $aWatermark; $this->position = $aPosition; $this->watermarkOpacity = Args::int($watermarkOpacity, 'watermark opacity')->min(0)->max(127)->value(); }
public function __construct($radius = 20, Color $color = null) { $this->radius = Args::int($radius, 'radius')->required()->min(0)->max(360)->value(); $this->color = $color ? $color : new Color('ffffff'); }
/** * Create a new ImageFilterDarken * * @param int $aRate -255 = min brightness, 0 = no change, +255 = max brightness */ public function __construct($rate = 20) { $this->rate = Args::int($rate)->required()->min(-255)->max(255)->value() * -1; }
/** * Creates a new CenteredPixelStrategy * * @param $aNewWidth int * @param $aNewHeight int * @param $aRespectSmallerImage boolean */ public function __construct($newWidth, $newHeight, $respectSmallerImage = true) { $this->newWidth = Args::int($newWidth, 'newWidth')->required()->min(0)->value(); $this->newHeight = Args::int($newHeight, 'newHeight')->required()->min(0)->value(); $this->respectSmallerImage = Args::bool($respectSmallerImage, 'respect smaller image')->required()->value(); }
/** * Creates a new ImageFilterFlip * * @param boolean $aHorizontal Flip horizontal * @param boolean $aVertical Flip vertical * */ public function __construct($horizontal = true, $vertical = false) { $this->horizontal = Args::bool($horizontal)->required()->value(); $this->vertical = Args::bool($vertical)->required()->value(); }
/** * Creates a new ImageFilterContrast * * @param int $aLevel -100 to +100, defaults to 5, where -100 = min contrast, 0 = no change, +100 = max contrast */ public function __construct($level = 5) { $this->level = Args::int($level, 'level')->required()->min(-100)->max(100)->value() * -1; }
/** * * @param number $aOffset */ public function __construct($offset = 4) { $this->offset = Args::int($offset, 'offset')->required()->min(1)->value(); }
/** * Creates a new ImageFilterSmooth * * @param int $aRate Smoothness level. */ public function __construct($rate = 5) { $this->rate = Args::int($rate, 'rate')->required()->min(0)->value(); }
/** * Creates a new MaxPixelStrategy. * * @param int $aMaxWidth * @param int $aMaxHeight */ public function __construct($maxWidth, $maxHeight) { $this->maxWidth = Args::int($maxWidth, 'maxWidth')->required()->min(0)->value(); $this->maxHeight = Args::int($maxHeight, 'maxHeight')->required()->min(0)->value(); }
/** * Constructor * @param number $aOpacity A value between 0 and 127. 0 indicates completely opaque while 127 indicates completely transparent. */ public function __construct($opacity = 80) { $this->opacity = Args::int($opacity)->required()->min(0)->max(127)->value(); }
/** * Constructor * * @param number $aOpacity from 0 to 100 */ public function __construct($opacity = 40) { $this->opacity = Args::int($opacity, 'opacity')->required()->min(0)->max(100)->value(); }
/** * Creates a new Pixelate filter * @param int $aBlocksize the blocksize in pixels */ public function __construct($blocksize = 20) { $this->blocksize = Args::int($blocksize, 'blocksize')->required()->min(1)->value(); }
/** * Outputs an image to browser or file. * * @param string path to save the image to on disk, null to output to the browser * @param string image type to render * @param int quality of the image * * @return boolean true on success, false on failure * * @deprecated use either ImageResource::render() or ImageResource::save() */ public final function imageoutput($path = null, $type = ImageType::PNG, $quality = 80) { Args::int($quality, 'quality')->min(1)->max(100)->required(); if (!is_resource($this->getResource())) { throw new ImageResourceException('This is not a resource'); } $result = false; ob_start(); switch ($type) { case ImageType::PNG: imagesavealpha($this->getResource(), true); // quality for png must be 0 - 9 $result = imagepng($this->getResource(), $path, $quality / 10 - 1, PNG_ALL_FILTERS); break; case ImageType::GIF: $result = imagegif($this->getResource(), $path); // gif does not have quality break; // default = jpg // default = jpg default: $result = imagejpeg($this->getResource(), $path, $quality); $type = ImageType::JPG; break; } $size = ob_get_length(); if (!headers_sent()) { header('Content-Type: image/' . $type); header("Content-Length: " . $size); } ob_end_flush(); return $result; }
/** * Creates a new ImageFilterSepia * * @param int $aDarken */ public function __construct($darken = 15) { $this->darken = Args::int($darken, 'darken')->required()->min(0)->value(); }