hplip-pstotiff-is-rubbish.patch 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. diff -up hplip-3.15.2/fax/filters/pstotiff.pstotiff-is-rubbish hplip-3.15.2/fax/filters/pstotiff
  2. --- hplip-3.15.2/fax/filters/pstotiff.pstotiff-is-rubbish 2015-02-04 09:40:43.169147058 +0100
  3. +++ hplip-3.15.2/fax/filters/pstotiff 2015-02-04 09:47:20.786983832 +0100
  4. @@ -1,45 +1,16 @@
  5. -#!/usr/bin/env python
  6. -
  7. -import os
  8. -import os.path
  9. -import time
  10. -import sys
  11. -import tempfile
  12. -
  13. -PY3 = sys.version_info[0] == 3
  14. -
  15. -READ_SIZE = 8192
  16. -
  17. -total_bytes_read = 0
  18. -temp_in_file = "-"
  19. -
  20. -if (len(sys.argv) > 6):
  21. - temp_in_file = sys.argv[6]
  22. -
  23. -temp_out_handle, temp_out_fname = tempfile.mkstemp()
  24. -
  25. -font = "-I/usr/share/cups/fonts"
  26. -device = "-sDEVICE=tiffg4 -dMaxStripSize=0 -r204x196 -dNOPAUSE -dBATCH -dSAFER -dPARANOIDSAFER -dSHORTERRORS -dWRITESYSTEMDICT -dGHOSTSCRIPT -sstdout=%stderr -sOutputFile=" + temp_out_fname + " " + temp_in_file
  27. -
  28. -gs_command = "/usr/bin/gs" + " " + font + " " + device
  29. -
  30. -exit_code = os.system(gs_command)
  31. -
  32. -file_len = os.stat(temp_out_fname).st_size
  33. -if (file_len < READ_SIZE):
  34. - READ_SIZE = file_len
  35. -
  36. -os.close(temp_out_handle)
  37. -
  38. -out_handle = open(temp_out_fname, mode='rb')
  39. -while (total_bytes_read < file_len):
  40. - data = out_handle.read(READ_SIZE)
  41. - if PY3:
  42. - sys.stdout.buffer.write(data)
  43. - else:
  44. - sys.stdout.write(data)
  45. - total_bytes_read += READ_SIZE
  46. -out_handle.close()
  47. -
  48. -os.remove(temp_out_fname)
  49. -sys.exit(0)
  50. +#!/bin/sh
  51. +if [ $# -lt 6 ]; then
  52. + IN=-_
  53. +else
  54. + IN="$6"
  55. +fi
  56. +
  57. +TMPFILE=`mktemp /tmp/pstotiff.XXXXXX` || exit 1
  58. +gs -I/usr/share/cups/fonts -sDEVICE=tiffg4 -dMaxStripSize=0 -r204x196 \
  59. + -dNOPAUSE -dBATCH -dSAFER -dPARANOIDSAFER \
  60. + -dSHORTERRORS -dWRITESYSTEMDICT -dGHOSTSCRIPT \
  61. + -sstdout=%stderr -sOutputFile="$TMPFILE" "$IN"
  62. +RET=$?
  63. +cat "$TMPFILE"
  64. +rm -f "$TMPFILE"
  65. +exit $RET