Page 1 of 1

Anti-aliasing/blurring images

Posted: Wed May 19, 2004 11:52 am
by pickle
Hi All,

I've recently written a little script to generate thumbnails of images I've uploaded. I've noticed though, that the resized thumbnails don't look as good as they would in, say, Photoshop. While I have no delusions to being able to duplicate Photoshop with PHP and gd, I was wondering how close I could get? I was thinking maybe using anti-aliasing somehow, or perhaps blurring the image a bit after creation. Does anyone have any leads on how to do this? Thanks a bunch.

Posted: Wed May 19, 2004 12:03 pm
by feyd
afaik, there's no built-in functions for blurring. So, creating a convolver is the next best route. You pass a matrix of numbers (2 dimensional array) containing the weighting of neighboring pixels. Each pixel is read, along with it's neighbors and run through the matrix.. it's quite time consuming, but you can get interesting results playing around with the matrix.

For instance, you can pass a matrix that'd blur or do edge detection or many other things.

You could also create your own scaling routine that does subpixel sampling or bilinear/trilinear filtering of the stretch.

Posted: Wed May 19, 2004 12:20 pm
by pickle
feyd wrote: So, creating a convolver is the next best route. You pass a matrix of numbers (2 dimensional array) containing the weighting of neighboring pixels. Each pixel is read, along with it's neighbors and run through the matrix.. it's quite time consuming, but you can get interesting results playing around with the matrix.

For instance, you can pass a matrix that'd blur or do edge detection or many other things.

You could also create your own scaling routine that does subpixel sampling or bilinear/trilinear filtering of the stretch.
Or I can say to heck with it - it's not that necessary. :wink: Thanks for the heads up though.

Posted: Wed May 19, 2004 1:22 pm
by feyd
sure thing.. I plan on building a large graphics library for all us boy-o's when I get some time with some built-in convolution stuffs.. probably make it as near photoshop as possible.. maybe dreaming, but I've done it in the past. :D