Example #1
0
function pHashWithDCT($file)
{
    $hash = array();
    $image = imagecreatefromstring(file_get_contents($file));
    $image = resizetosquare($image, 8);
    $image = grayscale($image);
    $dct = optimizedImgDTC($image);
    foreach ($dct as $key => $val) {
        $avg = array_average($val);
        foreach ($dct[$key] as $bit => $bit_val) {
            if ($bit_val < $avg) {
                array_push($hash, 0);
            } else {
                array_push($hash, 1);
            }
        }
    }
    return $hash;
}
Example #2
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 #3
0
require_once "index.php";
$base_url = "http://115.29.144.170/pictureEditor";
$target_path = "./upload/";
//接收文件目录
$file_name = $_FILES['uploadedfile']['name'];
$init_string = $file_name;
$edit_group = explode("@", $file_name)[0];
$edit_type = explode("@", $file_name)[1];
$file_name = explode("@", $file_name)[2];
$now_time = time();
$target_path = $target_path . $now_time . "_" . basename($file_name);
if (move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) {
    if ($edit_group == '1') {
        switch ($edit_type) {
            case '1':
                grayscale('./upload/' . $now_time . "_" . $file_name, './edit/' . $now_time . "_" . $file_name);
                break;
            case '2':
                blur('./upload/' . $now_time . "_" . $file_name, './edit/' . $now_time . "_" . $file_name);
                break;
            case '3':
                gammaCorrection('./upload/' . $now_time . "_" . $file_name, './edit/' . $now_time . "_" . $file_name);
                break;
            case '4':
                colorize('./upload/' . $now_time . "_" . $file_name, './edit/' . $now_time . "_" . $file_name, explode("@", $init_string)[3]);
                break;
            case '5':
                imageWatermarking('./upload/' . $now_time . "_" . $file_name, './edit/' . $now_time . "_" . $file_name);
                break;
            default:
                break;