imageconvolution
Description
The imageconvolution of Image for PHP apply a 3x3 convolution matrix, using coefficient and offset.
Syntax
imageconvolution( GdImage $image, array $matrix, float $divisor, float $offset ): bool
Parameters
image
A GdImage object, returned by one of the image creation functions, such as imagecreatetruecolor().
matrix
A 3x3 matrix: an array of three arrays of three floats.
divisor
The divisor of the result of the convolution, used for normalization.
offset
Color offset.
Return
Returns true on success or false on failure.
Examples
1 · return
<? $width = 100; $height = 100; $image = imagecreatetruecolor($width, $height); $matrix = array( array(1, 2, 1), array(2, 4, 2), array(1, 2, 1) ); $divisor = 16; $offset = 0; $return = imageconvolution($image, $matrix, $divisor, $offset); var_export($return);
true
2 · base64
<? $width = 100; $height = 100; $image = imagecreatetruecolor($width, $height); $red = 255; $green = 255; $blue = 255; $color = imagecolorallocate($image, $red, $green, $blue); $font = 1; $x = 0; $y = 0; $string = "string"; imagestring($image, $font, $x, $y, $string, $color); $matrix = array( array(1, 2, 1), array(2, 4, 2), array(1, 2, 1) ); $divisor = 16; $offset = 0; imageconvolution($image, $matrix, $divisor, $offset); ob_start(); imagepng($image); $output = ob_get_clean(); echo '<!doctype html> <html> <body> <img src="data:image/png;base64,' . base64_encode($output) . '"> </body> </html>';
<!doctype html> <html> <body> <img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGQAAABkCAIAAAD/gAIDAAAACXBIWXMAAA7EAAAOxAGVKw4bAAABY0lEQVR4nO3VwW3CQBCF4ZfE950jN7aE7QCXQKmUQAlDB0sH4yO3HEasEhQURQI5Qv93QWZ3Lc/TePyh70opm81G0uVy0U9+3fDC3m+ua63zPNda7x0ws1qrmT33uf6lqZSSxUdERLTW5nmW1HuXNEKJiGVZxmZJpZR7qxHRe1+WZZWSnmfa7/etNUnu3nuvV2ZmZhlcFu/uZtZaM7Pe+81qnm2t1Voj4nA4nE6nVUt7vCmLjwh9KTsi8nVrrUVExjS6bzRXrvbe8yY31i7t8aaMaWSRuUgaL5S7H49HSblT17GVwbl7vrySst1WK+X5pvzJBhn1jywkufv5fM5t2+024xg5unte5vFxcCT7St52u52uYeVIzsk9Oi6Hd+6++Rro2m75T04xM8sQX2/Avz3wXhmlpJf8FAIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAB/8wmnpfCseDqsYwAAAABJRU5ErkJggg=="> </body> </html>
Links
Image
- gd_info
- getimagesize
- getimagesizefromstring
- image_type_to_extension
- image_type_to_mime_type
- imageaffine
- imageaffinematrixconcat
- imageaffinematrixget
- imagealphablending
- imageantialias
- imagearc
- imageavif
- imagebmp
- imagechar
- imagecharup
- imagecolorallocate
- imagecolorallocatealpha
- imagecolorat
- imagecolorclosest
- imagecolorclosestalpha
- imagecolorclosesthwb
- imagecolordeallocate
- imagecolorexact
- imagecolorexactalpha
- imagecolormatch
- imagecolorresolve
- imagecolorresolvealpha
- imagecolorset
- imagecolorsforindex
- imagecolorstotal
- imagecolortransparent
- imagecopy
- imagecopymerge
- imagecopymergegray
- imagecopyresampled
- imagecopyresized
- imagecreate
- imagecreatefromavif
- imagecreatefrombmp
- imagecreatefromgif
- imagecreatefromjpeg
- imagecreatefrompng
- imagecreatefromstring
- imagecreatefromtga
- imagecreatefromwbmp
- imagecreatefromwebp
- imagecreatefromxbm
- imagecreatefromxpm
- imagecreatetruecolor
- imagecrop
- imagecropauto
- imagedashedline
- imagedestroy
- imageellipse
- imagefill
- imagefilledarc
- imagefilledellipse
- imagefilledpolygon
- imagefilledrectangle
- imagefilltoborder
- imagefilter
- imageflip
- imagefontheight
- imagefontwidth
- imageftbbox
- imagefttext
- imagegammacorrect
- imagegetclip
- imagegetinterpolation
- imagegif
- imageinterlace
- imageistruecolor
- imagejpeg
- imagelayereffect
- imageline
- imageloadfont
- imageopenpolygon
- imagepalettecopy
- imagepalettetotruecolor
- imagepng
- imagepolygon
- imagerectangle
- imageresolution
- imagerotate
- imagesavealpha
- imagescale
- imagesetbrush
- imagesetclip
- imagesetinterpolation
- imagesetpixel
- imagesetstyle
- imagesetthickness
- imagesettile
- imagestring
- imagestringup
- imagesx
- imagesy
- imagetruecolortopalette
- imagettfbbox
- imagettftext
- imagetypes
- imagewbmp
- imagewebp
- imagexbm
- iptcembed
- iptcparse