0.9.0 - the ZapV version updated to current php standards. Brave search used, while Bing and Google search api are deprecated
This commit is contained in:
parent
3d4298fe8b
commit
4ddaddda3d
31 changed files with 1778 additions and 1 deletions
92
lib/ImgProcess.class.php
Executable file
92
lib/ImgProcess.class.php
Executable file
|
|
@ -0,0 +1,92 @@
|
|||
<?php
|
||||
/**
|
||||
* ImgProcess
|
||||
* Actual image manipulation
|
||||
*/
|
||||
class ImgProcess {
|
||||
private $folder; //folder for reading source images and write
|
||||
|
||||
private $canvasName;
|
||||
|
||||
private $zapWidth;//collage dimensions
|
||||
|
||||
private $zapHeight;
|
||||
|
||||
private $maxRGB; //depends on colorDepth. 8 bits: 255; 16 bits : 65536;
|
||||
|
||||
/**
|
||||
* constructor
|
||||
* @param $imgFolder string
|
||||
* @param $width int
|
||||
* @param $height int
|
||||
* @param $nr int
|
||||
*/
|
||||
public function __construct($imgFolder, $width, $height, $nr) {
|
||||
$this->folder = $imgFolder;
|
||||
|
||||
$this->zapWidth = $width;
|
||||
$this->zapHeight = $height;
|
||||
|
||||
$this->canvasName = DIRECTORY_SEPARATOR . ZAP_CANVAS_NAME;
|
||||
$this->canvasName .= $_SESSION['date'] . "_nr_" . sprintf("%02d", $nr);
|
||||
|
||||
$tmpImg = new Imagick();
|
||||
$tmpAr = $tmpImg->getQuantumRange();
|
||||
$this->maxRGB = $tmpAr['quantumRangeLong'];
|
||||
$tmpImg->destroy();
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes a basic canvasFile from sourceImage
|
||||
* and saves it into imageFolder
|
||||
* returns imageBLOB from saved image
|
||||
* @param string $sourceImgName
|
||||
* @return void
|
||||
*/
|
||||
public function createBasicCanvas($sourceImgName) {
|
||||
$canvas = new Imagick($sourceImgName);
|
||||
$canvas = ImgTools::zoomCrop($canvas, $this->zapWidth, $this->zapHeight, TRUE);
|
||||
|
||||
ImgIOTools::saveImg($canvas, $this->folder, $this->canvasName);
|
||||
if (ZAP_DELETE_SOURCE == true) {
|
||||
unlink($sourceImgName);
|
||||
}
|
||||
ImgIOTools::onScreen($canvas);
|
||||
}
|
||||
|
||||
/**
|
||||
* adds processed version of $sourceImage to canvas
|
||||
* @param string $sourceImgName
|
||||
* @return void
|
||||
*/
|
||||
public function addToCanvas($sourceImgName) {
|
||||
$canvasUri = $this->folder . $this->canvasName . '.' . ZAP_IMG_TYPE;
|
||||
$canvas = new Imagick($canvasUri);
|
||||
|
||||
$source_im = new Imagick($sourceImgName);
|
||||
|
||||
$newCanvas_im = $this->zapToCanvas($source_im, $canvas);
|
||||
ImgIOTools::saveImg($newCanvas_im, $this->folder, $this->canvasName);
|
||||
if (ZAP_DELETE_SOURCE == true) {
|
||||
unlink($sourceImgName);
|
||||
}
|
||||
ImgIOTools::onScreen($newCanvas_im);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Imagick $source_im
|
||||
* @param Imagick $canvas
|
||||
* @return Imagick Object
|
||||
*/
|
||||
private function zapToCanvas(Imagick $source_im, $canvas) {
|
||||
//$val = ImgTools::imgCenterValueProm($source_im, $this->maxRGB);
|
||||
|
||||
//merge resized random transparised image on top of canvas
|
||||
$transparent = ImgTools::transparantRandom($source_im, $this->maxRGB);
|
||||
$resized = ImgTools::resize($transparent, $this->zapWidth, $this->zapHeight);
|
||||
|
||||
$canvas->compositeImage($resized, imagick::COMPOSITE_OVER, 0, 0);
|
||||
return $canvas;
|
||||
}
|
||||
}
|
||||
?>
|
||||
Loading…
Add table
Add a link
Reference in a new issue