PHP imageconvolution Function: Using div and offset to Create a 3×3 Convolution Matrix

The PHP imageconvolution function applies a 3×3 convolution matrix to an image resource, allowing specification of a divisor and offset for normalization and color adjustment, with detailed parameter descriptions, return values, and a complete example code snippet.

Laravel Tech Community
Laravel Tech Community
Laravel Tech Community
PHP imageconvolution Function: Using div and offset to Create a 3×3 Convolution Matrix

The imageconvolution function in PHP applies a 3×3 convolution matrix to an image resource, allowing you to specify a divisor and an offset for normalization and color adjustment.

Parameters

image – an image resource created by functions such as imagecreatetruecolor().

matrix – a 3×3 array of floating‑point numbers (array of arrays).

div – the divisor applied to the convolution result for scaling.

offset – a color offset added after convolution.

Return value

Returns TRUE on success or FALSE on failure.

Example

<?php
$image = imagecreatefromgif('http://www.php.net/images/php.gif');
$emboss = array(
    array(2,0,0),
    array(0,-1,0),
    array(0,0,-1)
);
imageconvolution($image, $emboss, 1, 127);
header('Content-Type: image/png');
imagepng($image, null, 9);
?>
Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

Backendimage-processingConvolutionimageconvolution
Laravel Tech Community
Written by

Laravel Tech Community

Specializing in Laravel development, we continuously publish fresh content and grow alongside the elegant, stable Laravel framework.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.