'version' => $version,
'out' => $out];
-
$cachekey = 'filefrompdf_' . hash('sha256', print_r($attrs, true));
$params = array_merge($attrs, ['toolbox' => 1,
protected $finish = false;
- public function __construct($document, $page, $format = 'jpg', $resolution = 150,$quality=85, $withText = true, $withGraphics = true, $version = 'html', $forceCheck = false, $forceProcess = false)
+ protected $path = "";
+
+ public function __construct($document, $page, $format = 'jpg', $resolution = 150, $quality = 85, $withText = true, $withGraphics = true, $version = 'html', $forceCheck = false, $forceProcess = false)
{
$this->onQueue('fluidbookprocess');
$this->document = $document;
$this->page = $page;
$this->format = $format;
$this->resolution = $resolution;
- $this->quality=$quality;
+ $this->quality = $quality;
$this->withGraphics = $withGraphics;
$this->withText = $withText;
$this->version = $version;
$this->forceCheck = $forceCheck || $forceProcess;
$this->forceProcess = $forceProcess;
+
+ $this->path = $this->document->_getPath($this->page, $this->format, $this->resolution, $this->quality, $this->withText, $this->withGraphics, $this->version);
}
public function handle()
{
$this->finish = false;
- echo $this->document->getFile($this->page, $this->format, $this->resolution,$this->quality, $this->withText, $this->withGraphics, $this->version, $this->forceCheck, $this->forceProcess) . "\n";
+ echo $this->document->getFile($this->page, $this->format, $this->resolution, $this->quality, $this->withText, $this->withGraphics, $this->version, $this->forceCheck, $this->forceProcess) . "\n";
$this->finish = true;
}
public function isOK()
{
- return $this->document->hasFile($this->page, $this->format, $this->resolution,$this->quality, $this->withText, $this->withGraphics, $this->version, $this->forceCheck);
+ return $this->document->hasFile($this->page, $this->format, $this->resolution, $this->quality, $this->withText, $this->withGraphics, $this->version, $this->forceCheck);
}
public function isError()
{
return $this->finish && !$this->isOK();
}
+
+ /**
+ * @return mixed|string
+ */
+ public function getPath(): mixed
+ {
+ return $this->path;
+ }
}
$done++;
}
}
+ if (rand(1, 10) === 5) {
+ echo $done . '/' . $nbjobs . "\n";
+ }
return $done === $nbjobs;
}
{
$c = $this->book->composition[$page];
$doc = $this->book->getDocument($page);
- $job = new FluidbookDocumentFileProcess($doc, $c[1], $format, $resolution, $withText, $withGraphics, $version);
+ $quality = $this->book->JPEGQuality ?: 85;
+ $job = new FluidbookDocumentFileProcess($doc, $c[1], $format, $resolution, $quality, $withText, $withGraphics, $version);
+ $this->jobs[] = $job;
if ($job->isDone()) {
return;
}
+ echo $job->getPath() . "\n";
dispatch($job);
- $this->jobs[] = $job;
+
}
}
}
if ($format === 'svg') {
$version = 'html';
- } else if ($format === 'swf') {
- $version = '';
}
if ($resolution === 'thumb') {
}
$file .= '.svg';
} else if ($format === 'png' || $format === 'jpg') {
- $q = ($format === 'jpg' && $quality !== 85) ? '-' . $quality : '';
+ $q = ($format === 'jpg' && $quality != 85) ? '-' . $quality : '';
$prefix = $withText ? 't' : 'h';
if ($resolution === 'thumb') {
$file = $dir . 'p' . $page . $q . '.' . $format;
} else {
$file = $dir . $prefix . $page . '-' . $resolution . $q . '.' . $format;
}
- } else if ($format === 'swf') {
- $file = $dir . 'p' . $page . '.' . $format;
}
return $file;
protected function fileCacheKey($page, $format = 'jpg', $resolution = 150, $quality = 85, $withText = true, $withGraphics = true, $version = 'html')
{
$this->_normalize($format, $resolution, $quality, $withText, $withGraphics, $version);
- return 'FluidbookDocument_' . $this->id . '_' . $page . '_' . $format . '_' . $resolution . '_' . ($withText ? '1' : '0') . '_' . ($withGraphics ? '1' : '0') . '_' . $version;
+ return 'FluidbookDocument_' . $this->id . '_' . $page . '_' . $format . '_' . $resolution . '_' . $quality . '_' . ($withText ? '1' : '0') . '_' . ($withGraphics ? '1' : '0') . '_' . $version;
}
public function getFile($page, $format = 'jpg', $resolution = 150, $quality = 85, $withText = true, $withGraphics = true, $version = 'html', $forceCheck = false, $forceProcess = false)
return Farm::getFileFromPDF($thumbpdf, $page, $format, $resolution, $this->JPEGQuality, $withText, $withGraphics, $version, null, $force);
}
}
- return $this->getFile($page, $format, $resolution, $this->JPEGQuality, $withText, $withGraphics, $version, $force);
+ return $this->getFile($page, $format, $resolution, $withText, $withGraphics, $version, $force);
}