$in = $this->in;
}
+ if (!$force && file_exists($this->infos)) {
+ return;
+ }
+
$fwstk = new cubeCommandLine('fwstk.sh');
$fwstk->setPath(CONVERTER_PATH);
$fwstk->setArg('--input ' . $in);
$dir = rtrim($this->out . $version, '/') . '/';
+ $minsize = 1;
if ($format === 'svg') {
$prefix = $withGraphics ? 'f' : 't';
$file = $dir . $prefix . 'o' . $page;
$file .= '-' . $resolution;
}
$file .= '.svg';
+ $reffile = $this->makeSVGFile($page);
+ $minsize = 100;
} else if ($format === 'png' || $format === 'jpg') {
$prefix = $withText ? 't' : 'h';
if ($resolution === 'thumb') {
$file = $dir . 'p' . $page . '.' . $format;
} else {
$file = $dir . $prefix . $page . '-' . $resolution . '.' . $format;
+ $alt = $dir . $prefix . $resolution . '-' . $page . '.' . $format;
}
}
+
+ $do = false;
if (!file_exists($file)) {
+ if (isset($alt) && file_exists($alt)) {
+ rename($alt, $file);
+ $do = false;
+ } else {
+ $do = true;
+ }
+ } else if (filesize($file) < $minsize) {
+ $do = true;
+ } else if (isset($reffile) && filemtime($file) < filemtime($reffile)) {
+ $do = true;
+ }
+
+ if ($do) {
$this->makeFile($file, $page, $format, $resolution, $withText, $withGraphics, $version);
}
return $file;
}
- public function makeFile($file, $page, $format = 'jpg', $resolution = 150, $withText = true, $withGraphics = true)
+ public function makeFile($file, $page, $format = 'jpg', $resolution = 150, $withText = true, $withGraphics = true, $version = 'html')
{
+ $lock = $file . '.lock';
+ if (file_exists($lock) && filemtime($lock) > time() - 300) {
+ sleep(10);
+ return $this->getFile($page, $format, $resolution, $withText, $withGraphics, $version);
+ }
+ touch($lock);
if ($format === 'jpeg') {
$format = 'jpg';
}
if ($resolution === 'thumb') {
wsPDFConvert::makeMiniShot($this->getSplittedPDFPage($page), $file, 1, $format);
} else {
- $rr = version === 'html' ? $this->getResolutionRatio() : $this->getMobileFirstRatio();
+ $rr = $version === 'html' ? $this->getResolutionRatio() : $this->getMobileFirstRatio();
wsPDFConvert::makeShotPNM($this->getSplittedPDFPage($page), $file, 1, '', $resolution * $rr, 85, 4, $withText, null, null, $format);
}
}
+ unlink($lock);
}
public function cutDocument($mode)
{
$svgFile = $this->out . '/html/fp' . $page . '.svg';
if (!$force && file_exists($svgFile) && filesize($svgFile) > 0) {
- return;
+ return $svgFile;
}
wsPDFConvert::makeBaseSVGFile($this->getSplittedPDFPage($page), $svgFile, 1);
return $svgFile;
public function makeTextSVGFile($page, $out, $force = false)
{
$in = $this->makeSVGFile($page);
- $do = $force || !file_exists($out) || filesize($out) < 100 || filemtime($in) > filemtime($out) || filemtime($out) < filemtime(__FILE__);
- if (!$do) {
- return;
- }
wsPDFConvert::makeTextSVGFile($in, $out);
wsTools::optimizeSVG($out, $out);
}
{\r
\r
// Fabrication des thumbanails avec ghostscript\r
- $gs = new cubeCommandLine('gs', null, true);\r
+ $gs = new CubeIT_CommandLine('gs', null, true);\r
$gs->setPath(CONVERTER_PATH);\r
$gs->setEnv('GS_FONTPATH', FONT_PATH);\r
$gs->setArg('-dBATCH');\r
$antialiasing = $antialiasing ? 'yes' : 'no';\r
$freetype = $texts ? 'yes' : 'no';\r
// Exporte les fichiers\r
- $pdftoppm = new cubeCommandLine('/usr/local/bin/pdftoppm', null, true);\r
+ $pdftoppm = new CubeIT_CommandLine('/usr/local/bin/pdftoppm', null, true);\r
$pdftoppm->setPath(CONVERTER_PATH);\r
\r
$pdftoppm->setArg('f', $page);\r