return $this->filesdata;
}
- public function getFile($page, $format = 'jpg', $resolution = 150, $withText = true, $withGraphics = true, $version = 'html', $force = false)
+ public function getFile($page, $format = 'jpg', $resolution = 150, $quality = 85, $withText = true, $withGraphics = true, $version = 'html', $force = false)
{
$this->getFilesData();
- $cacheKey = md5($page . '||' . $format . '//' . $resolution . '""' . ($withText ? '1' : '0') . '---' . ($withGraphics ? '1' : '0') . '%%' . $version);
+ $cacheKey = md5($page . '||' . $format . '$$' . $quality . '//' . $resolution . '""' . ($withText ? '1' : '0') . '---' . ($withGraphics ? '1' : '0') . '%%' . $version);
if ($force || !isset($this->filesdata[$cacheKey]) || !$this->filesdata[$cacheKey]) {
- $this->filesdata[$cacheKey] = $this->_getFile($page, $format, $resolution, $withText, $withGraphics, $version, $force);
+ $res=$this->_getFile($page, $format, $resolution, $quality, $withText, $withGraphics, $version, $force);
+ $this->filesdata[$cacheKey] = $res;
}
return $this->filesdata[$cacheKey];
}
return trim($response->getBody());
}
- public function _getFileFarm($page, $format = 'jpg', $resolution = 150, $withText = true, $withGraphics = true, $version = 'html', $force = false)
+ public function _getFileFarm($page, $format = 'jpg', $resolution = 150, $quality = 85, $withText = true, $withGraphics = true, $version = 'html', $force = false)
{
$start = microtime(true);
$farmer = self::pickOneFarmServer($this->region);
- $params = ['page' => $page, 'format' => $format, 'resolution' => $resolution, 'withText' => $withText, 'withGraphics' => $withGraphics, 'version' => $version, 'force' => $force, 'out' => $this->out, 'resolutionRatio' => $this->getResolutionRatio(), 'mobileRatio' => $this->getMobileFirstRatio()];
+ $params = ['page' => $page, 'format' => $format, 'resolution' => $resolution, 'quality' => $quality, 'withText' => $withText, 'withGraphics' => $withGraphics, 'version' => $version, 'force' => $force, 'out' => $this->out, 'resolutionRatio' => $this->getResolutionRatio(), 'mobileRatio' => $this->getMobileFirstRatio()];
try {
$output = self::sendRequest($farmer, 'process.php', $params);
if (preg_match('|/data1/extranet/www/[^\s]+|', $output, $matches)) {
}
$time = round(microtime(true) - $start, 4);
- $log = '[' . $farmer['name'] . ']' . "\t" . date('Y-m-d H:i:s') . "\t\t\t\t" . $time . "\t\t\t\t$page|$format|$resolution|$withText|$withGraphics|$version\t\t\t\t$res\t\t\t\t$output\n";
+ $log = '[' . $farmer['name'] . ']' . "\t" . date('Y-m-d H:i:s') . "\t\t\t\t" . $time . "\t\t\t\t$page|$format|$resolution|$quality|$withText|$withGraphics|$version\t\t\t\t$res\t\t\t\t$output\n";
$fp = fopen(wsDocument::getDir($this->document_id) . 'farm.log', 'a+');
fwrite($fp, $log);
return $res;
}
- public static function isFarmUser()
- {
- global $core;
- return true;
- $farmTesters = [1, 2, 3, 5, 446, 4135];
- if (!$core->user) {
- return false;
- }
- return in_array($core->user->utilisateur_id, $farmTesters);
- }
-
- public function _getFile($page, $format = 'jpg', $resolution = 150, $withText = true, $withGraphics = true, $version = 'html', $force = false)
+ public function _getFile($page, $format = 'jpg', $resolution = 150, $quality = 85, $withText = true, $withGraphics = true, $version = 'html', $force = false)
{
global $core;
$version = '';
}
- $isFarmUser = self::isFarmUser();
$dir = rtrim($this->out . $version, '/') . '/';
$minsize = 1;
$file .= '-' . $resolution;
}
$file .= '.svg';
- if ($isFarmUser) {
- $reffile = $this->out . '/html/fp' . $page . '.svg';
- } else {
- $reffile = $this->makeSVGFile($page, $force);
- }
+
+ $reffile = $this->out . '/html/fp' . $page . '.svg';
+
$minsize = 100;
} else if ($format === 'png' || $format === 'jpg') {
+ $q = ($format === 'jpg' && $quality != 85) ? $quality : '';
$prefix = $withText ? 't' : 'h';
if ($resolution === 'thumb') {
$file = $dir . 'p' . $page . '.' . $format;
} else {
- $file = $dir . $prefix . $page . '-' . $resolution . '.' . $format;
+ $file = $dir . $prefix . $page . '-' . $resolution . $q . '.' . $format;
}
} else if ($format === 'swf') {
$file = $dir . 'p' . $page . '.' . $format;
if ($do || $force) {
- if ($isFarmUser) {
- return $this->_getFileFarm($page, $format, $resolution, $withText, $withGraphics, $version, $force);
- } else {
- $this->makeFile($file, $page, $format, $resolution, $withText, $withGraphics, $version);
- }
+ return $this->_getFileFarm($page, $format, $resolution, $quality, $withText, $withGraphics, $version, $force);
} else {
touch($file);
}
return $file;
}
- 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 ($format === 'svg') {
- if ($withGraphics) {
- $this->makeOptimizedSVGFile($page, $resolution, $file);
- } else {
- $this->makeTextSVGFile($page, $file);
- }
- } else if ($format === 'png' || $format === 'jpg') {
- $e = explode('-', $resolution);
- if (count($e) > 1) {
- $resolution = $e[0];
- $quality = $e[1];
- } else {
- $quality = 85;
- }
-
- if ($resolution === 'thumb') {
- wsPDFConvert::makeMiniShot($this->getSplittedPDFPage($page), $file, 1, $format);
- } else {
- $rr = $version === 'html' ? $this->getResolutionRatio() : $this->getMobileFirstRatio();
- wsPDFConvert::makeShotPNM($this->getSplittedPDFPage($page), $file, 1, '', $resolution * $rr, $quality, 4, $withText, null, null, $format);
- }
- } else if ($format === 'swf') {
- wsPDFConvert::makeSWF($this->getSplittedPDFPage($page), $file, 1, $resolution, 80);
- }
- unlink($lock);
- }
-
public function cutDocument($mode)
{
$fwstk = new cubeCommandLine('fwstk.sh');
if ($force) {
$this->addToLog('Processing page #' . $page);
// Thumb for composition panel
- $this->getFile($page, 'jpg', 'thumb', true, true, '', true);
+ $this->getFile($page, 'jpg', 'thumb', 85, true, true, '', true);
// Image for link editor
- $this->getFile($page, 'jpg', 150, true, true, 'html', true);
+ $this->getFile($page, 'jpg', 150, 85, true, true, 'html', true);
// Make SVG base file
$this->makeSVGFile($page, true);
}