| 160 | |
| 161 | def throughTiffMultiPage24NC(self, dpi) : |
| 162 | """Converts the input file to TIFF format, X dpi, 24 bits per pixel, uncompressed. |
| 163 | Returns percents of ink coverage and number of pages. |
| 164 | """ |
| 165 | self.logdebug("Converting input datas to TIFF...") |
| 166 | self.infile.seek(0) |
| 167 | (handle, filename) = tempfile.mkstemp(".tmp", "pkpgcounter") |
| 168 | os.close(handle) |
| 169 | command = 'gs -sDEVICE=tiff24nc -dPARANOIDSAFER -dNOPAUSE -dBATCH -dQUIET -r%i -sOutputFile="%s" -' % (dpi, filename) |
| 170 | child = popen2.Popen4(command) |
| 171 | try : |
| 172 | data = self.infile.read(pdlparser.MEGABYTE) |
| 173 | while data : |
| 174 | child.tochild.write(data) |
| 175 | data = self.infile.read(pdlparser.MEGABYTE) |
| 176 | child.tochild.flush() |
| 177 | child.tochild.close() |
| 178 | except (IOError, OSError), msg : |
| 179 | raise pdlparser.PDLParserError, "Problem during conversion to TIFF : %s" % msg |
| 180 | |
| 181 | child.fromchild.close() |
| 182 | try : |
| 183 | child.wait() |
| 184 | except OSError, msg : |
| 185 | raise pdlparser.PDLParserError, "Problem during conversion to TIFF : %s" % msg |
| 186 | |
| 187 | result = inkcoverage.getPercents(filename) |
| 188 | try : |
| 189 | os.remove(filename) |
| 190 | except : |
| 191 | pass |
| 192 | return result |