Example #1
0
 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;
 }
Example #2
0
 public function handle()
 {
     global $ID;
     global $INPUT;
     $this->file = Projects_file::file($ID);
     $old_text = $INPUT->post->str($this->old_input_name(), '');
     $old = $this->split($old_text);
     $new_text = $INPUT->post->str($this->new_input_name(), '');
     $new = $this->split($new_text);
     $diff = new Diff($old, $new);
     $now = $this->now();
     if ($new == $now) {
         return "show";
     }
     if ($old != $now) {
         $check = new Diff($old, $now);
         $merged = merge3($diff->edits, $check->edits);
         if ($merged['conflict']) {
             global $MERGED_DIFF;
             $MERGED_DIFF = $merged['merged'];
             return $this->action();
         }
         $diff->edits = $merged['merged'];
         $new = $diff->closing();
     }
     lock($ID);
     $text = $this->update($this->merge($new));
     if ($text === FALSE) {
         msg('file has been changed, cannot save!', -1);
     } else {
         saveWikiText($ID, $text, "");
     }
     unlock($ID);
     return "show";
 }