| 1 | package URI::Title::Image; | ||
| 2 | $URI::Title::Image::VERSION = '1.902'; | ||
| 3 | use warnings; | ||
| 4 | use strict; | ||
| 5 | |||
| 6 | use Image::Size; | ||
| 7 | |||
| 8 | sub types {( | ||
| 9 | 'image/gif', | ||
| 10 | 'image/jpg', | ||
| 11 | 'image/jpeg', | ||
| 12 | 'image/png', | ||
| 13 | 'image/x-png', | ||
| 14 | )} | ||
| 15 | |||
| 16 | sub title { | ||
| 17 | my ($class, $url, $data, $type) = @_; | ||
| 18 | my $name = ( split m{/}, $url )[-1]; | ||
| 19 | |||
| 20 | my ($x, $y) = imgsize(\$data); | ||
| 21 | $type =~ s!^[^/]*/!!; | ||
| 22 | $type =~ s!^x-!!; | ||
| 23 | return $x && $y | ||
| 24 | ? "$name ($type ${x}x${y})" | ||
| 25 | : "$name ($type)"; | ||
| 26 | } | ||
| 27 | |||
| 28 | 1; | ||
| 29 | |||
| 30 | __END__ |