Name

Frame( ) — surround the image with a border

Synopsis

$image->Frame(geometry=>geometry,
                           width=>integer,
                           height=>integer,
                           inner=>integer,
                           outer=>integer,
                           color=>string)

Frame( ) adds a simulated three-dimensional border around the image, as shown in Figure 5.7. Width and height specify the line width of the vertical and horizontal sides of the frame, respectively (geometry may be used as a shortcut for width and height). The inner and outer parameters indicate the line width of the inner and outer “shadows” of the frame; a wider shadow gives the effect of a deeper frame. The width and height must both be larger than the sum of the inner and outer values if the method is to work properly.

$image->Frame(geometry => ’10x10', inner => 3, outer => 3)

Figure 5-7. $image->Frame(geometry => ’10x10', inner => 3, outer => 3)

Note that the width and height of the frame are added to the dimensions of the image. To create a frame that maintains the original dimensions of the image, crop the image before applying the frame:

# Make a frame that hugs the inside border of an image, # retaining its dimensions my ($w, $h) = $image->Get('columns', 'rows'); # First crop the image $image->Crop(width=>$w-20, # width and height indicate the area height=>$h-20, # to be cropped x=>10, # x and y indicate the offset y=>10); # Now add the Frame $image->Frame(width=>10, # here width and height are the line widths height=>10, # of the vertical and horizontal borders inner=>3, ...

Get Programming Web Graphics with Perl and GNU Softwar now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.