I'm looking for a PHP script that renders table data as image, but blurs out the content after, for example, the fifth row.
My example is from Wikipedia.
Some commercial websites / newspapers try to tease their customer by showing the preview of some data, but pixelate the lowest part of it.
Now I have to do such an unfair thing, too. Do you know any PHP library that already supports this? I wasn't able to figure out a good name for what I need, so it was difficult to find something good.
Thanks in advance.
You could create the table as you do now. Then use Imagick to blur everything after some y (line coordinate). Sorry I only know Imagemagick which is used by Imagick, not Imagick itself. Here is how I would do it in Imagemagick. I would blur the input image. Then I would create a mask image that was black above your desired line and white below it. Then I would composite the input, blurred image using the mask to get your desired results. I have taken your image above and processed it this way:
bottomy=676
wd=`convert image.png -format "%w" info:`
ht=`convert image.png -format "%h" info:`
convert image.png \( -clone 0 -blur 0x5 \) \( -size ${wd}x${bottomy} xc:black -background white -extent ${wd}x${ht} \) -composite result.png
You can get the width and height of your input in PHP directly. Then use the Imagick blurImage() to blur a copy. See http://us3.php.net/manual/en/imagick.blurimage.php
Then create the mask using newImage() for the black part http://us3.php.net/manual/en/imagick.newimage.php. Then use extendImage() for the white part. See http://us3.php.net/manual/en/imagick.extentimage.php
Then do the composite. See http://us3.php.net/manual/en/imagick.compositeimage.php
However, it looks like compositeImage() only allows two images. So you must create the mask and put it into the alpha channel of the blurred image. Then negate the mask and put it into the alpha channel of the input image. That can be done with compositeImage() using COMPOSITE_COPYOPACITY. Once you have that done, you can flattenImages() the two images together to make the output. See http://us3.php.net/manual/en/imagick.flattenimages.php