## extracted and simplified from a bit of working code I have my $fname = "/path/to/your/file.jpg"; my $text = "What you want to say."; open (IMG, "<$fname") or die; my $size = -s $fname; my $data; read IMG, $data, $size; close IMG; die "blah" unless $data; use GD; # my $itype = image_type(getType_bymagic($data)); # die unless $itype eq "Jpeg"; # my $method = "newFrom${itype}Data"; my $method = "newFromJpegData"; my $i = GD::Image->$method($data, 1); my $fg = $i->colorAllocate(102,102,102); $i->string(gdMediumBoldFont,7,7,$text,$fg); return \$i->png;