git.shiar.nl
/
minime.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
c35b75e
)
summarise file type and dimensions
author
Mischa POSLAWSKY
<perl@shiar.org>
Sun, 9 Feb 2020 21:01:17 +0000
(22:01 +0100)
committer
Mischa POSLAWSKY
<perl@shiar.org>
Sun, 9 Feb 2020 21:01:17 +0000
(22:01 +0100)
termimg
patch
|
blob
|
history
diff --git
a/termimg
b/termimg
index 4deee150e845031f965179380863084a65cab731..bec4a4bbbd1a7b148a195378abbdd09470b5e6e4 100755
(executable)
--- a/
termimg
+++ b/
termimg
@@
-2,17
+2,30
@@
use 5.014;
my ($file, $size) = @ARGV;
use 5.014;
my ($file, $size) = @ARGV;
+my @info = eval {
+ require Image::ExifTool;
+ my $exif = Image::ExifTool->new->ImageInfo($file);
+ return (
+ " $exif->{MIMEType}",
+ $exif->{ImageSize} ? " $exif->{ImageSize} ($exif->{Megapixels}MP)" : (),
+ $exif->{ColorType} ? " $exif->{BitDepth}bpp $exif->{ColorType}" : (),
+ );
+} or warn $@;
+
open my $pgm, '-|', convert => (
-compress => 'none',
'+distort' => SRT => '0,0 1,.56 0',
-thumbnail => $size || '66x23',
$file => 'pgm:-'
) or die $!;
open my $pgm, '-|', convert => (
-compress => 'none',
'+distort' => SRT => '0,0 1,.56 0',
-thumbnail => $size || '66x23',
$file => 'pgm:-'
) or die $!;
-<$pgm> eq "P2\n" or die "ascii pgm input required\n";
+<$pgm> eq "P2\n" or do {
+ say for @info;
+ exit 1;
+};
<$pgm>; <$pgm>; # ignore depth, dimensions
my @ch = split //, " .:coO@";
while (<$pgm>) {
print $ch[ $_ * @ch >> 8 ] for /\d+/g;
<$pgm>; <$pgm>; # ignore depth, dimensions
my @ch = split //, " .:coO@";
while (<$pgm>) {
print $ch[ $_ * @ch >> 8 ] for /\d+/g;
- print $/;
+ print $
info[$. - 4], $
/;
}
}