imageconvolution leaves black dot in the upper left corner

Posted by Peter O. on Stack Overflow See other posts from Stack Overflow or by Peter O.
Published on 2012-10-16T15:22:42Z Indexed on 2012/10/20 11:01 UTC
Read the original article Hit count: 263

Filed under:
|
|
|

I'm trying to sharp resized images using this code:

imageconvolution($imageResource, array(
        array( -1, -1, -1 ),
        array( -1, 16, -1 ),
        array( -1, -1, -1 ),
    ), 8, 0);

When the transparent PNG image is sharpened, using code above, it appears with a black dot in the upper left corner (I have tried different convolution kernels, but the result is the same). After resizing the image looked OK.

1st image is the original one

2nd image is the sharpened one

Original image Sharpen image

EDIT: What am I going wrong? I'm using the color retrieved from pixel.

$color = imagecolorat($imageResource, 0, 0);
    imageconvolution($imageResource, array(
        array( -1, -1, -1 ),
        array( -1, 16, -1 ),
        array( -1, -1, -1 ),
    ), 8, 0);
            imagesetpixel($imageResource, 0, 0, $color);

Is imagecolorat the right function? Or is the position correct?

EDIT2: I have changed coordinates, but still no luck. I've check the transparency given by imagecolorat (according to this post). This is the dump:

array(4) {
   red => 0
   green => 0
   blue => 0
   alpha => 127
}

Alpha 127 = 100% transparent. Those zeroes might cause the problem...

© Stack Overflow or respective owner

Related posts about php

Related posts about transparent