Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Image anti-aliasing using GD and Image::Magick

by giulienk (Curate)
on Dec 08, 2001 at 18:36 UTC ( [id://130413]=perlquestion: print w/replies, xml ) Need Help??

giulienk has asked for the wisdom of the Perl Monks concerning the following question:

How can I apply the anti-aliasing offered by Image::Magick upon an image created with GD::Graph?
I tried
my $image = Image::Magick->new; my $x = $image->Read('myGDGraphImage.png'); $image->Set(antialias=>'True'); $x = $image->Write('mySupposedToBeAliased.png');
but it's not working: setting an attribute is obvioulsy not like manipulating the image.
So maybe i'm looking the wrong way and there is anti-aliasing support in GD? Other modules supporting anti-aliasing? Or maybe Image::Magick can do it but i'm not able to make it work?
Thank you.

gkinueliileunikg

Replies are listed 'Best First'.
Re: Image anti-aliasing using GD and Image::Magick
by Masem (Monsignor) on Dec 08, 2001 at 20:20 UTC
    While not knowing the programming logistics behind it, typically in graphics work, you have to apply anti-aliasing as you paint to the image; you cannot take an image and make it anti-alised. (You *could* play with blur and other options to make it appear AA'ed, but this is probably not what you want). So if you drew additional text to the image at this point (after you set the AA property) I'd expect that text to be AA'd, but nothing else on the image.

    -----------------------------------------------------
    Dr. Michael K. Neylon - mneylon-pm@masemware.com || "You've left the lens cap of your mind on again, Pinky" - The Brain
    "I can see my house from here!"
    It's not what you know, but knowing how to find it if you don't know that's important

Re: Image anti-aliasing using GD and Image::Magick
by hsmyers (Canon) on Dec 08, 2001 at 22:36 UTC

    Just glancing at the documentation for IM, setting the attribute is passive. At a guess, you would at least have to reload the image, but more likely, you would have to scale the image—for AA, often you go from a larger image to a smaller image. This creates a kind of 'super' pixel which is filtered to determine the new color value. I noticed that IM has plenty of filters and effects to play with, so there should be some combination that gets you what you are looking for. Try super search here and google looking for AA information. There is lots on the net, this is a big subject (AA, not necessarily IM)

    –hsm

      Thank you for your advice.
      I think i can get good results creating a larger image and then scaling it down with something like this:
      #this is the default example for GD::Graph3D use GD::Graph::bars3d; use Image::Magick; my @data = ( ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"], [ 1203, 3500, 3973, 2859, 3012, 3423, 1230] ); my $graph = new GD::Graph::bars3d( 800, 600 ); #BIG image $graph->set( x_label => 'Day of the week', y_label => 'Number of hits', title => 'Daily Summary of Web Site', ); my $gd = $graph->plot( \@data ); #here the interesting part my $image=Image::Magick->new(magick=>'png'); $image->BlobToImage($gd->png); $image->Resize(width=>400, height=>300); #small and anti-aliased one $image->Write('graph3d.png');

      gkinueliileunikg

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://130413]
Approved by root
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (1)
As of 2024-04-25 04:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found