From: Steinar H. Gunderson Date: Tue, 9 Aug 2005 14:33:25 +0000 (+0000) Subject: Don't make a PNG thumbnail if the PDF creation failed. X-Git-Url: https://git.sesse.net/?p=webpdf;a=commitdiff_plain;h=28bec6d326a508b3fa2877d6613b40e530881369 Don't make a PNG thumbnail if the PDF creation failed. --- diff --git a/createpdf.pl b/createpdf.pl index f33bbc5..0423330 100755 --- a/createpdf.pl +++ b/createpdf.pl @@ -153,24 +153,26 @@ EOF exit; } -# Make a thumbnail from the finished PDF, for later reference. (Output to -# stdout is so we make sure we get only the first page; it's the simplest -# hack I can find offhand. :-) ) -system("convert -resize 192x192 output/$pdf_filename png:- > output/$pdf_filename.png"); -open DESC, ">output/$pdf_filename.desc"; +my $size = -s "output/$pdf_filename"; -if ($url =~ /^http/i) { - $url =~ tr/\n//d; - print DESC "$url\n"; -} else { - $filename =~ tr/\n//d; - print DESC "$filename\n"; -} +if (defined($size) && $size > 0) { + # Make a thumbnail from the finished PDF, for later reference. (Output to + # stdout is so we make sure we get only the first page; it's the simplest + # hack I can find offhand. :-) ) + system("convert -resize 192x192 output/$pdf_filename png:- > output/$pdf_filename.png"); + open DESC, ">output/$pdf_filename.desc"; + + if ($url =~ /^http/i) { + $url =~ tr/\n//d; + print DESC "$url\n"; + } else { + $filename =~ tr/\n//d; + print DESC "$filename\n"; + } -close DESC; + close DESC; +} -my $size = -s "output/$pdf_filename"; - (my $sanitized_outname = $outname) =~ tr/a-zA-Z0-9. -/_/c; print "Content-type: application/pdf\n";