#!/usr/bin/perl -w use strict; use Image::Magick; my $image = Image::Magick->new; $image->Set(size=>'170x100'); my $rc = $image->Read("xc:black"); $image->Set(alpha => 'transparent'); $image->Set('transparent-color' => 'black'); $image->Draw(primitive=> 'circle',fill=>'red', points=>'50,50 13,50') +; $image->Draw(primitive=> 'circle',fill=>'red', points=>'120,50 157,50' +); $image->Draw(primitive=> 'rectangle',fill=>'red', points=>'50,13 120,8 +7'); $image->Draw(primitive=> 'circle',fill=>'black', points=>'50,50 25,50 +'); $image->Draw(primitive=> 'circle',fill=>'black', points=>'120,50 145,5 +0'); $image->Draw(primitive=> 'rectangle',fill=>'black', points=>'50,25 120 +,75'); $image->Draw(primitive=> 'circle',fill=>'red', points=>'60,50 40,50') +; $image->Draw(primitive=> 'circle',fill=>'red', points=>'110,50 130,50' +); $image->Draw(primitive=> 'rectangle',fill=>'red', points=>'60,30 110,7 +0'); $image->Set(matte=>1); $image->Set(gaussian=>'1x1'); #$image->Write("pant_mask.png"); # mogrify will get the inner black circle and set it transparent $image->Mogrify('transparent-color' => 'black'); #$image->Write("pant.png"); # make a clone to blur my $imb = $image->Clone(); $imb->Blur(radius=>0,sigma=>6); $imb->Shade(geometry=>'110x30',gray=>1); $imb->Normalize(channel=>'All'); $imb->Set(matte=>0); #$imb->Write("pantblur.png"); # do 2 composites to simulate the 3d effect $rc = $imb->Composite(gravity => "Center", compose=>'Overlay', image => $image, ); warn $rc if $rc; #$imb->Write("pant_z3d.png"); $rc = $imb->Composite(gravity => "Center", compose=>'DstIn' , image => $image); # add your text $imb->Annotate( pointsize=>36, text=>'Ant', stroke => 'black', fill => 'white', gravity => 'center', x=> 0, # offsets y=> 0, # offsets ); # need to reset the transparency $imb->Mogrify('transparent-color' => 'black'); $imb->Write("$0.png"); __END__

In reply to Transparent 3d logo/button with ImageMagick by zentara

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.