package Image::Filter::Blur; #Oki, so I cheated a bit by using Inline::C instead :) #Anyway, I owe alot to the fine folks on inline@perl.org and several monks here (derby, rob_au, zaxo) #I have some other filter code lying around #I plan to release this stuff to CPAN at some point, might change name tho #This is ofcourse a draft, cleaner subs etc should be added later on #call it : #use Filter::Image::Blur; #blur("inputpic.jpg","outputpic.jpg"); #Using PNG takes a little tweaking :) #Anyway, enjoy :) #Note: This is a BW based blur use 5.006; use strict; use vars qw($VERSION @ISA @EXPORT); use Exporter; @EXPORT = qw(blur); $VERSION = '0.01'; use Inline C => Config => LIBS => '-lgd -ljpeg', AUTO_INCLUDE => '#include "gd.h"'; use Inline C =>< 255 ? 255 : (newcolor < 0 ? 0 : newcolor); index = gdImageColorExact(imblur,newcolor,newcolor,newcolor); if (index == -1) { index = gdImageColorAllocate(imblur,newcolor,newcolor,newcolor); } gdImageSetPixel(imblur,w,h,index); } } out = fopen(outfile, "wb"); gdImageJpeg(imblur, out,-1); fclose(out); gdImageDestroy(im); gdImageDestroy(imblur); return 1; } EOC 1; __END__