Bio::G...::image(3pm)
π Bio::G...::image β the manual page, but make it make sense π
okay so bestie, welcome to the perl manual page for Bio::G...::image(3pm) β which is the lil doc for Bio::Graphics::Glyph::image, aka the glyph that drops photos and other pics right into your track. it's part of the User Contributed Perl Documentation crew. buckle up, we're rendering pixels. π
β¨ NAME β¨
Bio::Graphics::Glyph::image β a glyph that draws photographs & other images π¦
πΈ SYNOPSIS πΈ
use Bio::Graphics;
use Bio::Seq;
use Bio::SeqFeature::Generic;
my $bsg = 'Bio::SeqFeature::Generic';
my $seq = Bio::Seq->new(-length=>1000);
my $whole = $bsg->new(-display_name => 'Clone82',
-start => 1,
-end => $seq->length);
my $image1 = $bsg->new(-start => 100,
-end => 300,
-display_name => 'Excretory System',
-tag=>{
image=>"http://www.flybase.org/anatomy/image-browser_files/excretory-system.gif"
}
);
my $image2 = $bsg->new(-start => 500,
-end => 800,
-display_name => 'Expression Pattern',
-tag=>{
image=>"http://www.flybase.org/anatomy/image-browser_files/embryonic-expression-pattern.gif"
}
);
my $panel = Bio::Graphics::Panel->new(-length => $seq->length,
-width => 800,
-truecolor => 1,
-key_style => 'between',
-pad_left => 10,
-pad_right => 10,
);
$panel->add_track($whole,
-glyph => 'arrow',
-double => 1,
-tick => 2,
-label => 1,
);
$panel->add_track([$image1,$image2],
-glyph => 'image',
-label => 1,
-key => 'Example images');
binmode STDOUT;
print $panel->png;
π DESCRIPTION π
okay so real talk: this glyph literally inserts an image into the track, right at the feature coordinates you indicate. the tea: the image can be in PNG, JPEG, GIF or GD format, and it can be either 8-bit or 24-bit ("truecolor"). πΌοΈ and where can that image live? either on your local filesystem, or sitting pretty at a remote URL β provided you've got the LWP module installed. no LWP, no remote vibes, that's the deal. π«Ά
now, when you're working with photographic images, you might wanna have Bio::Graphics::Panel create 24-bit (truecolor) images, because otherwise you can straight up run out of colors π. the symptom of that? your images come out posterized. the glow-down nobody asked for. to turn on truecolor images, pass the -truecolor option to Bio::Graphics::Panel like the synopsis shows. periodt.
β¨ OPTIONS β¨
these next ones are standard among all Glyphs. for a full explanation, go see Bio::Graphics::Glyph. π
-fgcolorβ foreground color. default:black-outlinecolorβ synonym for-fgcolor-bgcolorβ background color. default:turquoise-fillcolorβ synonym for-bgcolor-linewidthβ line width. default:1-heightβ height of glyph. default:10-fontβ glyph font. default:gdSmallFont-connectorβ connector type. default:0 (false)-connector_colorβ connector color. default:black-labelβ whether to draw a label. default:0 (false)-descriptionβ whether to draw a description. default:0 (false)-hiliteβ highlight color. default:undef (no color)
and these extra ones? those are exclusive to the "image" glyph, bestie: π
-imageβ specify the image path or URL to use for this feature. default:none-image_prefixβ string to prepend to each image path. you may prepend a directory or a partial URL. default:none-vertical_spacingβ vertical distance from the box that shows the physical span of the feature to the top of the picture (in pixels). default:20-glyph_delegateβ glyph to use for the part of the glyph that shows the physical span of the feature. default:'generic'
set-vertical_spacingto0to completely suppress the diagonal lines that connect the physical span of the feature to the image. poof, gone. π¨
π¦ Specifying the Image π¦
so there's two ways to tell it where your image is. pick your fighter:
- drop it in the feature itself using a tag named
"image"πΈ - specify it as a track option using a callback π
$panel->add_track(\@features,
-glyph=>'image',
-image => sub { my $feature = shift;
my $image_path = do_something();
return $image }
);
and yes, you can of course hand -image a constant string, in which case every single feature will show the same image. lowkey efficient, highkey repetitive, whatever works. π
the image can be a file on the local operating system or a URL. HOWEVER β and this is the important part β URL fetching will only work if the LWP module is installed on your system. otherwise the glyph will fail with an error message. no cap. π
if the image is a relative path (meaning it does not begin with a slash or a URL protocol), then the contents of -image_prefix get prepended to it. this lets you specify images that are relative to a particular directory or a partial URL. example:
$panel->add_track(\@features,
-glyph => 'image',
-image_prefix => 'http://www.flybase.org/anatomy/image-browser_files',
);
so this specifies that each feature's "image" tag gets appended to the partial FlyBase URL β thereby saving space. iconic behavior, honestly. π
π§ Glyph Delegation π§
the image glyph is made of two parts:
- an upper part that shows the extent of the feature in base pair coordinates
- a lower part that shows the image
and ngl, no scaling of the image is done β its height and width are fixed. fr fr. π
by default the upper part uses the "generic" glyph, which is a simple rectangle filled with the bgcolor and outlined with the fgcolor. to use a different glyph up top, specify the -glyph_delegate option, giving the name of the glyph you wish to use. for instance, to use the "span" glyph:
$panel->add_track(\@features,
-glyph => 'image',
-glyph_delegate => 'span'
);
β οΈ this feature does not work with all glyphs, and in particular it requires a recent CVS checkout of Bio::Perl to work properly with the"arrow","span"and"primers"glyphs (support for the feature did not make it into version 1.5). so if it's acting up, that's why, don't blame yourself. π
π BUGS AND LIMITATIONS π
this glyph does not work with GD::SVG. if you try to render it onto a GD::SVG panel, the image will be shown as a gray box. π it's giving sad beige. this will be fixed in a future version of GD::SVG β until then, gray box it is.
π SEE ALSO π
Bio::Graphics::Panel, Bio::Graphics::Glyph, Bio::Graphics::Glyph::arrow, Bio::Graphics::Glyph::cds, Bio::Graphics::Glyph::crossbox, Bio::Graphics::Glyph::diamond, Bio::Graphics::Glyph::dna, Bio::Graphics::Glyph::dot, Bio::Graphics::Glyph::ellipse, Bio::Graphics::Glyph::extending_arrow, Bio::Graphics::Glyph::generic, Bio::Graphics::Glyph::graded_segments, Bio::Graphics::Glyph::heterogeneous_segments, Bio::Graphics::Glyph::line, Bio::Graphics::Glyph::pinsertion, Bio::Graphics::Glyph::primers, Bio::Graphics::Glyph::rndrect, Bio::Graphics::Glyph::segments, Bio::Graphics::Glyph::ruler_arrow, Bio::Graphics::Glyph::toomany, Bio::Graphics::Glyph::transcript, Bio::Graphics::Glyph::transcript2, Bio::Graphics::Glyph::translation, Bio::Graphics::Glyph::triangle, Bio::DB::GFF, Bio::SeqI, Bio::SeqFeatureI, Bio::Das, GD
π AUTHOR π
Lincoln Stein <lstein@cshl.org>, Todd Harris <harris@cshl.org>
Copyright (c) 2001 Cold Spring Harbor Laboratory
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See DISCLAIMER.txt for disclaimers of warranty.
and that's the whole page, bestie!! π«Ά this was perl v5.30.0, dated 2019-11-25, and it lives under the name Bio::G...::image(3pm). go forth and render something gorgeous. slay. β¨π
π
π¦ where this page comes from
- debian bookworm: libbio-graphics-perl 2.40-6 Β· Perl
- debian trixie: libbio-graphics-perl 2.40-6 Β· Perl
- ubuntu jammy: libbio-graphics-perl 2.40-6 Β· Perl
- ubuntu noble: libbio-graphics-perl 2.40-6 Β· Perl
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms