diff options
author | Guillermo Ramos | 2023-08-26 13:57:34 +0200 |
---|---|---|
committer | Guillermo Ramos | 2023-11-03 19:04:18 +0100 |
commit | 932c7c3aeba300f7998473e081f8b139d347de7c (patch) | |
tree | ff8ffe8479ab6227360efdf537257524cb043c84 | |
parent | cdf2bee81b33b8678c4cad9ca45f4f70b0a2d85f (diff) | |
download | bots-932c7c3aeba300f7998473e081f8b139d347de7c.tar.gz |
pegatino: improve error reporting
-rwxr-xr-x | pegatino.pl | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/pegatino.pl b/pegatino.pl index 1fa884b..1a732de 100755 --- a/pegatino.pl +++ b/pegatino.pl @@ -17,19 +17,24 @@ binmode STDIN; my $origimg = <>; my ($origh, $origpath) = tempfile(); +my $newpath = $origpath . ".png"; +# Prepare to read original file binmode $origh; print $origh $origimg; close $origh; +# Convert image my $imagick = Image::Magick->new; -$imagick->Read($origpath); -$imagick->Resize(geometry => '512x512'); - -my $newpath = $origpath . ".png"; -$imagick->Write($newpath); - -open(my $newh, "<", $newpath); +my $out = $imagick->Read($origpath); +die "ERROR: $out" if "$out"; +$out = $imagick->Resize(geometry => '512x512'); +die "ERROR: $out" if "$out"; +$out = $imagick->Write($newpath); +die "ERROR: $out" if "$out"; + +# Read new file +open(my $newh, "<", $newpath) or die $!; binmode $newh; my $newimg = <$newh>; close $newh; |