const BARBARE_PNM = 4;\r
const BARBARE_GS = 5;\r
\r
- const PNM_FILL = 6;\r
+ const PNM_FILL = 2;\r
\r
protected static $resolution2multiply = array(72 => 2, 100 => 2, 150 => 3, 200 => 3, 300 => 3, 450 => 4, 600 => 5);\r
// Number section styles\r
$this->makeShot($page, 'te', 150, 60, 4, 'GS', $this->uncropped);\r
}\r
\r
- public function makeShotFixedWidth($page , $prefix = '', $w = 100, $quality = 90, $antialiasing = 4, $method = 'GS')\r
+ public function makeShotFixedWidth($page , $prefix = '', $w = 100, $quality = 90, $antialiasing = 4, $method = 'PNM')\r
{\r
// Make thumbs of $w width\r
// resolution 72 make 1pt=1px\r
$this->makeShot($page, $prefix, round(72 / $ratio, 2), $quality, $antialiasing, $method);\r
}\r
\r
- public function makeShotFixedHeight($page , $prefix = '', $h = '', $quality = 90, $antialiasing = 4, $method = 'GS')\r
+ public function makeShotFixedHeight($page , $prefix = '', $h = '', $quality = 90, $antialiasing = 4, $method = 'PNM')\r
{\r
// Make thumbs of $w height\r
// resolution 72 make 1pt=1px\r
$this->makeShot($page, $prefix, round(72 / $ratio, 2), $quality, $antialiasing, $method);\r
}\r
\r
- public function makeShot($page , $prefix = '', $resolution = 72, $quality = 90, $antialiasing = 4, $method = 'GS', $in = null)\r
+ public function makeShot($page , $prefix = '', $resolution = 72, $quality = 90, $antialiasing = 4, $method = 'PNM', $in = null)\r
{\r
$error = false;\r
if (is_null($in)) {\r
$in = $this->cropped;\r
}\r
// Delete all old files\r
+ $res = $this->out . $prefix . $page . '.jpg';\r
+ if (file_exists($res)) {\r
+ @unlink($res);\r
+ }\r
+\r
if ($method == 'GS') {\r
$this->makeShotGS($page, $prefix, $resolution, $quality, $antialiasing, $in);\r
} elseif ($method == 'PNM') {\r
$this->makeShotPNM($page, $prefix, $resolution, $quality, $antialiasing, $in);\r
}\r
// Test the result by checking all files\r
- if (!file_exists($this->out . $prefix . $page . '.jpg')) {\r
+ if (!file_exists($res)) {\r
$error = true;\r
}\r
// If error, we try to make thumbs with other method\r
\r
$pdftoppm->setArg('-cropbox');\r
$pdftoppm->setArg('-freetype yes');\r
+ $pdftoppm->setArg('-jpeg');\r
$pdftoppm->setArg('-aa ' . $antialiasing);\r
$pdftoppm->setArg('-aaVector ' . $antialiasing);\r
$pdftoppm->setArg('r', $resolution);\r
$pdftoppm->execute();\r
$this->addToLog($pdftoppm, true, $page);\r
\r
- $startpage = is_null($page)?1:$page;\r
+ $ppmfile = $this->out . 'ppm-' . cubeMath::fill($page, self::PNM_FILL) . '.ppm';\r
+ $ppmjpgfile = $this->out . 'ppm-' . cubeMath::fill($page, self::PNM_FILL) . '.jpg';\r
+ $jpegfile = $this->out . $prefix . $page . '.jpg';\r
\r
- for($i = $startpage;true;$i++) {\r
- $ppmfile = $this->out . 'ppm-' . cubeMath::fill($i, PNM_FILL) . '.ppm';\r
- $jpegfile = $this->out . $prefix . $i . '.jpg';\r
- if (!file_exists($ppmfile)) {\r
- break;\r
- }\r
- $pnmtojpeg = new cubeCommandLine('pnmtojpeg', $jpegfile, false);\r
- $pnmtojpeg->setPath(CONVERTER_PATH);\r
- $pnmtojpeg->setArg('-quality=' . $quality);\r
- $pnmtojpeg->setArg('-density=' . $resolution . 'x' . $resolution . 'dpi');\r
- $pnmtojpeg->setManualArg($ppmfile);\r
- $pnmtojpeg->execute();\r
-\r
- $this->addToLog($pnmtojpeg, false, $i);\r
- unlink($ppmfile);\r
+ if (file_exists($ppmjpgfile)) {\r
+ rename($ppmjpgfile, $jpegfile);\r
+ $this->addToLog('Move ' . $ppmjpgfile . ' to ' . $jpegfile, true, $page);\r
}\r
}\r
\r