function createpng($tag = 0, $gray = 0, $fuzzy = 0, $x = 1, $y = 1, $d = 0, $borders = array()) { if ($this->createfromim == 1) { // just load image from im or filename $cim = $this->im; } else { // load from STB files $images = $this->getimagefilenames(); $this->doLog("ps%+10"); // dumpvars($this); // now crop it if ($images === FALSE) { return FALSE; } $im = merge3($this->tileX, $this->tileY, $images); $this->doLog("image marged.."); $cim = cropimage($im, $this->movX, $this->movY, $this->shiftx * 315 + $fuzzy, $this->shifty * 315 + $fuzzy); } if ($tag == 1) { // echo "tag it ...\n"; $this->doLog("tag image.."); $cim = tagimage($cim, $this->startx, $this->starty, $fuzzy); } else { if ($tag == 2) { if ($this->outsizex == 0 || $this->outsizey == 0) { $this->err[] = "Please call setoutsize() first\n"; return FALSE; } if ($this->createfromim == 0 && ($this->shiftx < $this->outsizex || $this->shifty < $this->outsizey)) { // echo "resizing image...\n"; $dst = imageCreate($this->outsizex * 315 + $fuzzy, $this->outsizey * 315 + $fuzzy); $bgcolor = imagecolorallocate($dst, 255, 255, 255); imagefill($dst, 0, 0, $bgcolor); imageCopy($dst, $cim, 0, 0, 0, 0, imageSX($cim), imageSY($cim)); $cim = $dst; } // refer to X,Y, I // debug: echo "addtagbprder2 cim $x $y $d $this->startx, $this->starty, 4x6, $this->shiftx, $this->shifty $fuzzy \n"; $cim = addtagborder2($cim, $x, $y, $d, $this->startx, $this->starty, array("x" => $this->outsizex, "y" => $this->outsizey), $this->shiftx, $this->shifty, $fuzzy); $this->doLog("add border and index .."); if (!($x == 1 && $y == 1)) { // echo "add boder to cut or paste...\n"; $cim = addborder2($cim, $x, $y, $d, $borders); $this->doLog("add border .."); } } } if ($gray == 1) { // // echo "making it gray...\n"; $cim = grayscale($cim); } else { if ($gray == 2) { error_log("making it bright more and gray..."); if (function_exists('imagefilter')) { // echo "using imagefilter...\n"; error_log("using imagefilter"); // imagefilter($cim, IMG_FILTER_BRIGHTNESS, 21); imagefilter($cim, IMG_FILTER_CONTRAST, 100); } else { $cim = grayscale($cim); $this->doLog("grayscle image .."); } } } return $cim; }
function splitimage($im, $sizex, $sizey, $outfile, &$px, &$py, $fuzzy) { $w = imagesX($im); $h = imagesY($im); $count = 0; $py = 0; $total = ceil(($w - $fuzzy) / $sizex) * ceil(($h - $fuzzy) / $sizey); for ($j = 0; $j < $h - $fuzzy; $j += $sizey) { $py++; for ($i = 0; $i < $w - $fuzzy; $i += $sizex) { $outfname = $outfile . "_" . $count . ".png"; // overwrite if (!file_exists($outfname)) { $dst = cropimage($im, $i, $j, $sizex + $fuzzy, $sizey + $fuzzy); imagePNG($dst, $outfname); imageDestroy($dst); // overwrite } $imgs[$count++] = $outfname; //if (($bar=intval($count/$total*10))!=$lastbar) { // echo "= " . $bar*10 . "% "; $lastbar=$bar; // flush(); //} } } //echo "done\n"; $px = $count / $py; return $imgs; }