// We use the BookReaderTiff prefix to give a hint in case things don't
// get cleaned up.
$tempFile = tempnam("/tmp", "BookReaderTiff");
-
- if (1 != $scale) {
- if (onPowerNode()) {
- $pbmReduce = ' | pnmscale -reduce ' . $scale;
- } else {
- $pbmReduce = ' | pnmscale -nomix -reduce ' . $scale;
- }
- } else {
- $pbmReduce = '';
- }
+
+ $pbmReduce = reduceCommand($scale);
$decompressCmd =
' > ' . $tempFile . ' ; tifftopnm ' . $tempFile . ' 2>/dev/null' . $pbmReduce;
-
+
+} else if ('jpg' == $fileExt) {
+ $decompressCmd = ' | jpegtopnm ' . reduceCommand($scale);
+
} else {
BRfatal('Unknown source file extension: ' . $fileExt);
}
$compressCmd = ' | pnmtopng ' . $pngOptions;
}
-$cmd = $unzipCmd . $decompressCmd . $compressCmd;
+if (($ext == $fileExt) && ($scale == 1) && ($rotate === "0")) {
+ // Just pass through original data if same format and size
+ $cmd = $unzipCmd;
+} else {
+ $cmd = $unzipCmd . $decompressCmd . $compressCmd;
+}
# print $cmd;
return false;
}
+function reduceCommand($scale) {
+ if (1 != $scale) {
+ if (onPowerNode()) {
+ return ' | pnmscale -reduce ' . $scale;
+ } else {
+ return ' | pnmscale -nomix -reduce ' . $scale;
+ }
+ } else {
+ return '';
+ }
+}
+
?>
function findImageStack($subPrefix, $filesData) {
// $$$ Add jpeg here
- $imageFormats = array('TIFF' => 'tif', 'JP2' => 'jp2');
+ $imageFormats = array('TIFF' => 'tif', 'JP2' => 'jp2', 'JPEG' => 'jpg');
$archiveFormats = array('ZIP' => 'zip', 'Tar' => 'tar');
$imageGroup = implode('|', array_keys($imageFormats));
$archiveGroup = implode('|', array_keys($archiveFormats));
// $$$ TODO add support for jpg and tar stacks
// https://bugs.edge.launchpad.net/gnubook/+bug/323003
// https://bugs.edge.launchpad.net/gnubook/+bug/385397
- $imageFormatRegex = '@' . preg_quote($prefix, '@') . '_(jp2|tif)\.(zip|tar)$@';
+ $imageFormatRegex = '@' . preg_quote($prefix, '@') . '_(jp2|tif|jpg)\.(zip|tar)$@';
$baseLength = strlen($item->metadataGrabber->mainDir . '/');
foreach ($item->getFiles() as $location => $fileInfo) {