From ffa7bdfb3129550be4b509540917a389ae2ce197 Mon Sep 17 00:00:00 2001 From: "vincent@cubedesigners.com" Date: Tue, 2 Mar 2010 14:56:14 +0000 Subject: [PATCH] --- .../class.ws.conversion.session.php | 2 +- inc/ws/Metier/class.ws.document.php | 67 ++++++++++++------- 2 files changed, 42 insertions(+), 27 deletions(-) diff --git a/inc/ws/Controlleur/class.ws.conversion.session.php b/inc/ws/Controlleur/class.ws.conversion.session.php index d15820cb8..269ded484 100644 --- a/inc/ws/Controlleur/class.ws.conversion.session.php +++ b/inc/ws/Controlleur/class.ws.conversion.session.php @@ -64,7 +64,7 @@ class wsConversionSession { $this->currentDocPage = $i; $this->totalDocPage = $doc->generalInfos['pages']; $this->setProgress(($this->processedPages / $this->totalPages) * 100); - $this->currentDoc->processOnePage($i); + $this->currentDoc->processOnePage($i, false); $this->processedPages++; } $doc = $dao->updateFromObject($doc); diff --git a/inc/ws/Metier/class.ws.document.php b/inc/ws/Metier/class.ws.document.php index 72fad2527..9b5a26daa 100644 --- a/inc/ws/Metier/class.ws.document.php +++ b/inc/ws/Metier/class.ws.document.php @@ -20,8 +20,12 @@ class wsDocument extends cubeMetier { protected $bookmarks; protected $numberSections; protected $links; - protected $crop; - + // Crop & cut + protected $autocrop; + protected $manualcrop; + protected $autocut; + protected $manualcut; + // Files protected $out; protected $in; protected $uncompressed; @@ -72,16 +76,13 @@ class wsDocument extends cubeMetier { $this->parseInfos($pdfinfo . $pdftk); file_put_contents($this->infos, $pdfinfo . $pdftk); - $this->crop = $this->findCutDisposition(); + $this->findCutDisposition(); } public function findCutDisposition() { - $spreads = $this->detectSpreads(); - if ($spreads) { - return $spreads; - } - return $this->detectPageDifferences(); + $this->detectSpreads(); + $this->detectPageDifferences(); } protected function detectPageDifferences() @@ -106,15 +107,16 @@ class wsDocument extends cubeMetier { $heights = array_unique($heights); $widths = array_unique($widths); if (count($heights) == 1 && count($widths) == 1) { - return 'TTRIM'; + $this->autocrop = 'trim'; + $this->manualcrop = false; } else { - return 'TMANUEL'; + $this->autocrop = false; + $this->manualcrop = true; } } protected function detectSpreads() { - $spread = false; // Détection des spreads foreach($this->generalInfos['page'] as $page => $infos) { if ($page == 1) { @@ -128,24 +130,26 @@ class wsDocument extends cubeMetier { if ($first == $last && $last == $second) { $ratio = $first[0] / $first[1]; + $this->autocut = false; if ($ratio <= 1) { - return false; + $this->manualcut = false; } elseif ($ratio >= 6) { - return 'CSL8'; + $this->manualcut = 'L8'; } elseif ($ratio >= 3) { - return 'CSL4'; + $this->manualcut = 'L4'; } elseif ($ratio >= 2) { - return 'CSL3'; + $this->manualcut = 'L3'; } else { - return 'CS-14-23'; + $this->manualcut = '14-23'; } + return; } - + $this->manualcut = false; if ($first == $last && round($first[0] * 2) == round($second[0])) { - return 'C1-23-4'; + $this->autocut = '1-23-4'; } if (round($first[0] * 2) == round($second[0]) && $last == $second) { - return 'C1-23'; + $this->autocut = '1-23'; } } @@ -244,13 +248,22 @@ class wsDocument extends cubeMetier { $this->getTexts(); } - public function Crop() + public function CropAndCut() { - if ($this->crop == 'TTRIM') { + if ($this->autocrop == 'trim') { $this->trimDocument(); } else { copy($this->in, $this->cropped); } + + if ($this->autocut) { + $this->cutDocument($this->autocut); + } + } + + public function cutDocument($mode) + { + } public function trimDocument() @@ -275,12 +288,14 @@ class wsDocument extends cubeMetier { $this->addToLog($fwstk); } - public function processOnePage($page) + public function processOnePage($page, $force = true) { - $this->makeMiniShot($page); $this->makeRealShot($page); - $this->makeSWFFiles($page, 150, 90, true, 1800, 1); - $this->makeAS3($page); + if ($force || $this) { + $this->makeMiniShot($page); + $this->makeSWFFiles($page, 150, 90, true, 1800, 1); + $this->makeAS3($page); + } } public function processAllPages() @@ -393,7 +408,7 @@ class wsDocument extends cubeMetier { $gs->setArg('-dUseCIEColor'); $gs->setArg('-dAutoRotatePages=/None'); // Resolution & Quality - $gs->setArg('-r' . $resolution); + $gs->setArg('-r' . round($resolution)); $gs->setArg('-dJPEGQ=' . $quality); // Antialias $gs->setArg('-dDOINTERPOLATE'); -- 2.39.5