GBFatal("Bad id!"); } $imageFormat = 'unknown'; $zipFile = "$itemPath/{$id}_jp2.zip"; if (file_exists($zipFile)) { $imageFormat = 'jp2'; } else { $zipFile = "$itemPath/${id}_tif.zip"; if (file_exists($zipFile)) { $imageFormat = 'tif'; } } if ("unknown" == $imageFormat) { GBfatal("Unknown image format"); } $scanDataFile = "$itemPath/{$id}_scandata.xml"; $scanDataZip = "$itemPath/scandata.zip"; if (file_exists($scanDataFile)) { $scanData = simplexml_load_file($scanDataFile); } else if (file_exists($scanDataZip)) { $cmd = 'unzip -p ' . escapeshellarg($scanDataZip) . ' scandata.xml'; exec($cmd, $output, $retval); if ($retval != 0) GBFatal("Could not unzip ScanData!"); $dump = join("\n", $output); $scanData = simplexml_load_string($dump); } else if (file_exists("$itemPath/scandata.xml")) { // For e.g. Scribe v.0 books!
// work on a pipe (the file must be seekable). // We use the GnuBookTiff prefix to give a hint in case things don't // get cleaned up. $tempFile = tempnam("/tmp", "GnuBookTiff"); if (1 != $scale) { if (onPowerNode()) { $pbmReduce = ' | pnmscale -reduce ' . $scale; } else { $pbmReduce = ' | pnmscale -nomix -reduce ' . $scale; } } else { $pbmReduce = ''; } $decompressCmd = ' > ' . $tempFile . ' ; tifftopnm ' . $tempFile . ' 2>/dev/null' . $pbmReduce; } else { GBfatal('Unknown source file extension: ' . $fileExt); } } // Non-integer scaling is currently disabled on the cluster // if (isset($_REQUEST['height'])) { // $cmd .= " | pnmscale -height {$_REQUEST['height']} "; // } if ('jpg' == $ext) { $compressCmd = ' | pnmtojpeg ' . $jpegOptions; } else { if ('png' == $ext) { $compressCmd = ' | pnmtopng ' . $pngOptions; } } $cmd = $unzipCmd . $decompressCmd . $compressCmd; //print $cmd;