Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><strong>Introduction</strong></p> <p>I think you should get Imagemagick installed because what you want is a simple <code>vignette</code> effect, You can easily so that with <a href="http://php.net/manual/en/book.imagick.php" rel="noreferrer">ImageMagic</a> (<code>convert input.jpg -background black -vignette 70x80 output.png</code>) without having to loop every pixel which can be very slow when dealing with large images </p> <p><strong>Original Image</strong></p> <pre><code>$file = __DIR__ . "/golf.jpg"; </code></pre> <p><img src="https://i.stack.imgur.com/i04gl.jpg" alt="enter image description here"></p> <p><strong>Effect 1</strong></p> <pre><code>$image = new imagick($file); $image-&gt;vignetteImage(20, 20, 40, - 20); header("Content-Type: image/png"); echo $image; </code></pre> <p><img src="https://i.stack.imgur.com/dn0iR.jpg" alt="enter image description here"></p> <p><strong>Effect 2</strong></p> <pre><code>$image = new imagick($file); $image-&gt;vignetteImage(100, 100, 200, 200); header("Content-Type: image/png"); echo $image; </code></pre> <p><img src="https://i.stack.imgur.com/3Orcb.jpg" alt="enter image description here"></p> <p><strong>vignette with GD</strong></p> <p>Well if you are forced to use GB ... Use can use this <a href="http://www.php.net/manual/en/function.imagefilter.php#109809" rel="noreferrer">cool vignette script</a> </p> <pre><code>function vignette($im) { $width = imagesx($im); $height = imagesy($im); $effect = function ($x, $y, &amp;$rgb) use($width, $height) { $sharp = 0.4; // 0 - 10 small is sharpnes, $level = 0.7; // 0 - 1 small is brighter $l = sin(M_PI / $width * $x) * sin(M_PI / $height * $y); $l = pow($l, $sharp); $l = 1 - $level * (1 - $l); $rgb['red'] *= $l; $rgb['green'] *= $l; $rgb['blue'] *= $l; }; for($x = 0; $x &lt; imagesx($im); ++ $x) { for($y = 0; $y &lt; imagesy($im); ++ $y) { $index = imagecolorat($im, $x, $y); $rgb = imagecolorsforindex($im, $index); $effect($x, $y, $rgb); $color = imagecolorallocate($im, $rgb['red'], $rgb['green'], $rgb['blue']); imagesetpixel($im, $x, $y, $color); } } return (true); } </code></pre> <p><strong>Faster GD vignette approach</strong></p> <p>A better approached used in <a href="https://github.com/marchibbins/GD-Filter-testing" rel="noreferrer">GD Filter testing</a> would be ... to create a mask and over lay</p> <pre><code> $overlay = 'vignette_white.png'; $png = imagecreatefrompng($overlay); imagecopyresampled($filter, $png, 0, 0, 0, 0, $width, $height, $width, $height); </code></pre> <ul> <li><a href="https://github.com/marchibbins/GD-Filter-testing/blob/master/process.php" rel="noreferrer">Full Code</a> </li> <li><a href="http://marchibbins.com/dev/gd/" rel="noreferrer">Cool Demos Of the filter combination</a></li> </ul> <p>The only disadvantage is that The image must be the same size with the mask for the effect to look cool</p> <p><strong>Conclusion</strong> </p> <p>If this is what you mean by <code>radial transparent gradient</code> then i advice you to get <code>ImageMagic</code> if not at least the lady the picture is cute.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload