Anti-aliasing/blurring images

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Anti-aliasing/blurring images

Post 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.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post 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.
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Post 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.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post 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
Post Reply