0

0

phpimageeditor 修改后自用

php中文网

php中文网

发布时间:2016-08-08 09:27:33

|

1130人浏览过

|

来源于php中文网

原创

下载组件phpimageeditor;
$ vim phpimageeditor/lite/shared/classes/phpimageeditor.php
覆盖
    class phpimageeditor {
    var $srcedit = "";
    var $name = "";
    var $srcoriginal = "";
    var $srcpng = "";
    var $srcworkwith = "";
    var $urlworkwith = "";
    var $resourceworkwith = false;
    var $mimetype = "";
    var $actionsaveandclose = "save";
    var $actionrotateleft = "rotate:90";
    var $actionrotateright = "rotate:-90";
    var $actiongrayscale = "grayscale";
    var $actioncontrast = "contrast";
    var $actionbrightness = "brightness";
    var $actionundo = "undo";
    var $actionupdate = "update";
    var $actionrotateisselected = false;
    var $actionrotate = "";
    var $actionseparatorsign = "#";
    var $fieldnamekeepproportions = "keepproportions";
    var $errormessages = array();
    var $formname = "phpimageeditor";
    var $inputwidth = -1;
    var $inputheight = -1;
    var $inputcropleft = 0;
    var $inputcropright = 0;
    var $inputcroptop = 0;
    var $inputcropbottom = 0;
    var $inputkeepproportions = true;
    var $inputcropkeepproportions = false;
    var $inputcropkeepproportionsratio = 1;
    var $inputpanel = pie_start_panel;
    var $inputlanguage = pie_default_language;
    var $inputcontrast = 0;
    var $inputbrightness = 0;
    var $inputcontrastlast = 0;
    var $inputbrightnesslast = 0;
    var $inputgrayscale = false;
    var $httpimagekey = "imagesrc";
    var $texts = array();
    var $actions = "";
    var $ispostback = false;
    var $isajaxpost = false;
    var $finalwidth = -1;
    var $finalheight = -1;
    var $widthkeepproportions = -1;
    var $heightkeepproportions = -1;
    var $userid = "";
    var $fonts = array();
    var $dosave = false;
    var $contrastmax = 100;
    var $brightnessmax = 255;
//    var $photoinfo = array();
   
    function phpimageeditor() {
        $this->loadlanguage();
        if (version_compare(phpversion(), pie_php_version_minimum, "            $this->errormessages[] = phpversion() . " " . $this->texts["old php version"] . " " . pie_php_version_minimum;
            return;
        }
        $this->ispostback = isset($_post["actiontype"]);
        $srcedit = "";
        if ($_get[$this->httpimagekey] != null) {
            $l = directory_separator;
            $file = dirname(dirname(dirname(dirname(__file__)))) . "{$l}tmp{$l}{$_get[$this->httpimagekey]}";
            #$srcedit = strip_tags($_get[$this->httpimagekey]);
            $srcedit = strip_tags($file);
        }
        if ($srcedit == "") {
            $this->errormessages[] = $this->texts["no provided image"];
            return;
        }
        $this->srcedit = urldecode($srcedit);
        if (isset($_post["userid"]))
            $this->userid = $_post["userid"];
        else {
            $this->userid = "_" . str_replace(".", "_", $_server['remote_addr']);
            #in my virtual box in windows vista i'll get :: as ip.
            #remove it to avoid errors.
            $this->userid = str_replace("_::", "", $this->userid);
        }
        $this->setsrcoriginal();
        $this->setsrcpng();
        $this->setsrcworkwith();
        if (!file_exists($this->srcedit)) {
            $this->errormessages[] = $this->texts["image does not exist"];
            return;
        }
        $info = getimagesize($this->srcedit);
        if (!$info) {
            $this->errormessages[] = $this->texts["invalid image type"];
            return;
        }
        $this->mimetype = image_type_to_mime_type($info[2]);
// echo image_type_to_mime_type($info[2])."===".image_type_to_mime_type(imagetype_jpeg);exit;
        if ($this->mimetype == image_type_to_mime_type(imagetype_jpeg) || $this->mimetype == image_type_to_mime_type(imagetype_gif) || $this->mimetype == image_type_to_mime_type(imagetype_png)) {
            if (!$this->ispostback)
                $this->saveoriginal();
            $this->resourceworkwith = $this->createimage($this->srcoriginal);
            $this->savepng();
            copy($this->srcpng, $this->srcworkwith);
            $this->resourceworkwith = $this->createimage($this->srcpng);
        }
        else {
            $this->errormessages[] = $this->texts["invalid image type"];
            return;
        }
        $this->finalwidth = $this->getwidth();
        $this->finalheight = $this->getheight();
        $this->widthkeepproportions = $this->getwidth();
        $this->heightkeepproportions = $this->getheight();
//        $this->photoinfo = $this->getuserdata();
        if ($this->ispostback) {
            $this->actionrotateisselected = (strip_tags($_post["rotate"]) != "-1");
            $this->actionrotate = strip_tags($_post["rotate"]);
            $this->actions = strip_tags($_post["actions"]);
            $this->isajaxpost = (strip_tags($_post["isajaxpost"]) == "true");
            $this->inputwidth = (int) strip_tags($_post["width"]);
            $this->inputheight = (int) strip_tags($_post["height"]);
            $this->inputcropleft = (int) strip_tags($_post["cropleft"]);
            $this->inputcropright = (int) strip_tags($_post["cropright"]);
            $this->inputcroptop = (int) strip_tags($_post["croptop"]);
            $this->inputcropbottom = (int) strip_tags($_post["cropbottom"]);
            $this->inputpanel = (int) strip_tags($_post["panel"]);
            $this->inputlanguage = strip_tags($_post["language"]);
            $this->inputkeepproportions = (strip_tags($_post["keepproportionsval"]) == "1");
            $this->inputcropkeepproportions = (strip_tags($_post["cropkeepproportionsval"]) == "1");
            $this->inputcropkeepproportionsratio = (float) strip_tags($_post["cropkeepproportionsratio"]);
            $this->inputgrayscale = (strip_tags($_post["grayscaleval"]) == "1");
            $this->inputbrightness = (int) strip_tags($_post["brightness"]);
            $this->inputcontrast = (int) strip_tags($_post["contrast"]);
            $this->inputbrightnesslast = (int) strip_tags($_post["brightnesslast"]);
            $this->inputcontrastlast = (int) strip_tags($_post["contrastlast"]);
            $this->action(strip_tags($_post["actiontype"]));
        }
    }
    function loadlanguage() {
        $language = "";
        if (isset($_post["language"])) {
            $this->inputlanguage = $_post["language"];
            $language = $this->inputlanguage;
        } else if (isset($_get["language"])) {
            $this->inputlanguage = $_get["language"];
            $language = $this->inputlanguage;
        } else
            $language = pie_default_language;
        $trylanguage = "language/" . $language . ".ini";
        if (file_exists($trylanguage))
            $this->texts = pie_gettexts("language/" . $language . ".ini");
        else
            $this->texts = pie_gettexts("language/" . pie_default_language . ".ini");
        //load the texts that not exists in the current langugare from english.
        $texts = pie_gettexts("language/en-gb.ini");
        foreach ($texts as $key => $text) {
            if (array_key_exists($key, $this->texts) === false)
                $this->texts[$key] = $text;
        }
    }
    function setsrcoriginal() {
        $arr = explode("/", $this->srcedit);
        $this->srcoriginal = pie_image_original_path . $this->adduseridtoimagesrc($arr[count($arr) - 1]);
    }
    function setsrcworkwith() {
        $arr = explode("/", $this->srcedit);
        $srcworkwith = pie_image_work_with_path . $this->adduseridtoimagesrc($arr[count($arr) - 1]);
        $srcworkwith = substr($srcworkwith, 0, strripos($srcworkwith, ".")) . ".png";
        $this->srcworkwith = $srcworkwith;
        //         $this->urlworkwith = $this->isajaxpost && $_post['actiontype'] == $this->actionsaveandclose
        //             ? "http://".str_replace(directory_separator,"/",str_replace(doc_root,$_server['server_name'],$this->srcedit))
        //             : "http://".str_replace(directory_separator,"/",str_replace(doc_root,$_server['server_name'],$srcworkwith))
        //             ;
        if ($_post['actiontype'] == $this->actionsaveandclose) {
            $this->urlworkwith = "http://" . str_replace(directory_separator, "/", str_replace(doc_root, $_server['server_name'], $this->srcedit));
            #               echo "ajax:{$this->urlworkwith}";
        } else {
            $this->urlworkwith = "http://" . str_replace(directory_separator, "/", str_replace(doc_root, $_server['server_name'], $srcworkwith));
            #              echo "noajax:{$this->urlworkwith}";
        }
    }
    function setsrcpng() {
        $arr = explode("/", $this->srcedit);
        $srcpng = pie_image_png_path . $this->adduseridtoimagesrc($arr[count($arr) - 1]);
        $srcpng = substr($srcpng, 0, strripos($srcpng, ".")) . ".png";
        $this->srcpng = $srcpng;
    }
    function saveoriginal() {
        copy($this->srcedit, $this->srcoriginal);
        #resize to fit in max width/height.
        $imagetmp = $this->createimage($this->srcoriginal);
        $finalwidth = $this->getwidthfromimage($imagetmp);
        $finalheight = $this->getheightfromimage($imagetmp);
        $dosave = false;
        if ($finalwidth > pie_image_max_width) {
            $widthprop = pie_image_max_width / $finalwidth;
            $finalwidth = pie_image_max_width;
            $finalheight = round($finalheight * $widthprop);
            $dosave = true;
        }
        if ($finalheight > pie_image_max_height) {
            $heightprop = pie_image_max_height / $finalheight;
            $finalheight = pie_image_max_height;
            $finalwidth = round($finalwidth * $heightprop);
            $dosave = true;
        }
        if ($dosave) {
            $imagetmp = $this->actionresize($finalwidth, $finalheight, $imagetmp);
            $this->saveimage($imagetmp, $this->srcoriginal);
        }
    }
    function savepng() {
        $this->saveimage($this->resourceworkwith, $this->srcpng, image_type_to_mime_type(imagetype_png));
    }
    function errorhasoccurred() {
        return (count($this->errormessages) > 0);
    }
    function getwidthfinal() {
        return $this->finalwidth;
    }
    function getheightfinal() {
        return $this->finalheight;
    }
    function getwidth() {
        return $this->getwidthfromimage($this->resourceworkwith);
    }
    function getwidthlast() {
        if ($this->ispostback)
            return (int) $_post["widthlast"];
        return $this->getwidth();
    }
    function getheight() {
        return $this->getheightfromimage($this->resourceworkwith);
    }
    function getheightlast() {
        if ($this->ispostback)
            return (int) $_post["heightlast"];
        return $this->getwidth();
    }
    function getwidthfromimage($image) {
        return imagesx($image);
    }
    function getheightfromimage($image) {
        return imagesy($image);
    }
    function action($actiontype) {
        $this->dosave = false;
        if ($actiontype == $this->actionundo) {
            $this->actionundo();
            $this->dosave = true;
        }
        if ($actiontype == $this->actionupdate || $actiontype == $this->actionsaveandclose) {
            if ($this->inputwidth != $this->getwidthlast() || $this->inputheight != $this->getheightlast())
                $this->actions .= $this->getactionseparator() . "resize:" . $this->inputwidth . "," . $this->inputheight;
            if ($this->inputcropleft != 0 || $this->inputcropright != 0 || $this->inputcroptop != 0 || $this->inputcropbottom != 0)
                $this->actions .= $this->getactionseparator() . "crop:" . $this->inputcropleft . "," . $this->inputcropright . "," . $this->inputcroptop . "," . $this->inputcropbottom;
            $this->dosave = true;
        }
        if ($actiontype == $this->actionupdate && $this->inputgrayscale) {
            if (strpos($this->actions, $this->actiongrayscale) === false) {
                $this->actions .= $this->getactionseparator() . $this->actiongrayscale . ":0";
                $this->dosave = true;
            }
        } else if ($actiontype == $this->actionupdate && !$this->inputgrayscale) {
            if (!(strpos($this->actions, $this->actiongrayscale) === false)) {
                $this->actions = str_replace($this->actiongrayscale . ":0" . $this->getactionseparator(), "", $this->actions);
                $this->actions = str_replace($this->getactionseparator() . $this->actiongrayscale . ":0", "", $this->actions);
                $this->actions = str_replace($this->actiongrayscale . ":0", "", $this->actions);
                $this->dosave = true;
            }
        }
        if ($this->inputcontrast != $this->inputcontrastlast) {
            $this->actions .= $this->getactionseparator() . $this->actioncontrast . ":" . $this->inputcontrast;
            $this->dosave = true;
        }
        if ($this->inputbrightness != $this->inputbrightnesslast) {
            $this->actions .= $this->getactionseparator() . $this->actionbrightness . ":" . $this->inputbrightness;
            $this->dosave = true;
        }
        if ($this->actionrotateisselected) {
            if ($this->actionrotate == $this->actionrotateleft) {
                $this->actions .= $this->getactionseparator() . $this->actionrotateleft;
                $this->dosave = true;
            } else if ($this->actionrotate == $this->actionrotateright) {
                $this->actions .= $this->getactionseparator() . $this->actionrotateright;
                $this->dosave = true;
            }
        }
        $finalcontrast = 0;
        $finalbrightness = 0;
        $finalcontrastfound = false;
        $finalbrightnessfound = false;
        $finalgrayscale = false;
        if ($this->dosave && $this->actions != "") {
            $allactions = explode($this->actionseparatorsign, $this->actions);
            $finalrotate = 0;
            $finalcropleft = 0;
            $finalcropright = 0;
            $finalcroptop = 0;
            $finalcropbottom = 0;
            $doswitch = false;
            foreach ($allactions as $loopaction) {
                $actiondetail = explode(":", $loopaction);
                $actionvalues = explode(",", $actiondetail[1]);
                if ($actiondetail[0] == "resize") {
                    $this->finalwidth = (int) $actionvalues[0];
                    $this->finalheight = (int) $actionvalues[1];
                } else if ($actiondetail[0] == "crop") {
                    $actionvalueleft = (int) $actionvalues[0];
                    $actionvalueright = (int) $actionvalues[1];
                    $actionvaluetop = (int) $actionvalues[2];
                    $actionvaluebottom = (int) $actionvalues[3];
                    $widthprop = 1;
                    $heightprop = 1;
                    if ($doswitch) {
                        $widthprop = (($this->getheight() - ($finalcroptop + $finalcropbottom)) / $this->finalwidth);
                        $heightprop = (($this->getwidth() - ($finalcropleft + $finalcropright)) / $this->finalheight);
                    } else {
                        $widthprop = (($this->getwidth() - ($finalcropleft + $finalcropright)) / $this->finalwidth);
                        $heightprop = (($this->getheight() - ($finalcroptop + $finalcropbottom)) / $this->finalheight);
                    }
                    $cropleft = $actionvalueleft * $widthprop;
                    $cropright = $actionvalueright * $widthprop;
                    $croptop = $actionvaluetop * $heightprop;
                    $cropbottom = $actionvaluebottom * $heightprop;
                    $cropvalues = array();
                    $cropvalues[] = $cropright;
                    $cropvalues[] = $cropbottom;
                    $cropvalues[] = $cropleft;
                    $cropvalues[] = $croptop;
                    if ($finalrotate != 0)
                        $cropvalues = $this->rotatearray(($finalrotate / -90), $cropvalues);
                    $finalcropright += $cropvalues[0];
                    $finalcropbottom += $cropvalues[1];
                    $finalcropleft += $cropvalues[2];
                    $finalcroptop += $cropvalues[3];
                    $this->finalwidth -= ($actionvalueleft + $actionvalueright);
                    $this->finalheight -= ($actionvaluetop + $actionvaluebottom);
                }
                else if ($actiondetail[0] == $this->actiongrayscale && $this->inputgrayscale) {
                    $finalgrayscale = true;
                } else if ($actiondetail[0] == "contrast") {
                    $finalcontrastfound = true;
                    $finalcontrast = $actionvalues[0];
                } else if ($actiondetail[0] == "brightness") {
                    $finalbrightnessfound = true;
                    $finalbrightness = $actionvalues[0];
                } else if ($actiondetail[0] == "rotate") {
                    $finalrotate += (int) $actionvalues[0];
                    $finalwidthtmp = $this->finalwidth;
                    $this->finalwidth = $this->finalheight;
                    $this->finalheight = $finalwidthtmp;
                }
                if ($finalrotate == -360 || $finalrotate == 360)
                    $finalrotate = 0;
                $doswitch = ($finalrotate != 0 && ($finalrotate == 90 || $finalrotate == 270 || $finalrotate == -90 || $finalrotate == -270));
            }
            //1. all effects.
            if ($finalgrayscale)
                $this->actiongrayscale();
            if ($finalbrightnessfound)
                $this->actionbrightness($finalbrightness);
            if ($finalcontrastfound)
                $this->actioncontrast($finalcontrast * -1);
            //2. do cropping.
            $finalcropleft = round($finalcropleft);
            $finalcropright = round($finalcropright);
            $finalcroptop = round($finalcroptop);
            $finalcropbottom = round($finalcropbottom);
            if ($finalcropleft != 0 || $finalcropright != 0 || $finalcroptop != 0 || $finalcropbottom != 0)
                $this->actioncrop($finalcropleft, $finalcropright, $finalcroptop, $finalcropbottom);
            //3. rotate
            if ($finalrotate != 0)
                $this->actionrotate($finalrotate);
            //calculate keep proportions values.
            if (round($this->finalwidth / $this->finalheight, 1) == round($this->getwidth() / $this->getheight(), 1)) {
                //it seems to have the same proportions as the original. use the original proportions value.
                $this->widthkeepproportions = $this->getwidth();
                $this->heightkeepproportions = $this->getheight();
            } else {
                //the proportions has been changed. use the new width and height instead.
                $this->widthkeepproportions = $this->finalwidth;
                $this->heightkeepproportions = $this->finalheight;
            }
            //4. resize
            if ($this->finalwidth > 0 && $this->finalheight > 0)
                $this->resourceworkwith = $this->actionresize($this->finalwidth, $this->finalheight, $this->resourceworkwith);
            $this->saveimage($this->resourceworkwith, $this->srcworkwith, image_type_to_mime_type(imagetype_png));
        }
        $this->inputbrightness = $finalbrightness;
        $this->inputcontrast = $finalcontrast;
        $this->inputgrayscale = $finalgrayscale;
        if ($actiontype == $this->actionsaveandclose) {
            $this->saveimage($this->resourceworkwith, $this->srcedit, $this->mimetype);
            unlink($this->srcoriginal);
            unlink($this->srcpng);
            unlink($this->srcworkwith);
            pie_deleteoldimages(pie_image_original_path);
            pie_deleteoldimages(pie_image_png_path);
            pie_deleteoldimages(pie_image_work_with_path);
            $reloadparentbrowser = pie_reload_parent_browser_on_save ? 'window.opener.location.reload();' : '';
// pie_echo('<script language="javascript" type="text/javascript">'.$reloadparentbrowser.'window.open(\'\',\'_parent\',\'\');window.close();</script>');
        }
    }
    function actionresize($width, $height, $image) {
        $newimage = @imagecreatetruecolor($width, $height);
        pie_keeptranspacecycopyresampled($newimage, $this->mimetype);
        imagecopyresampled($newimage, $image, 0, 0, 0, 0, $width, $height, $this->getwidthfromimage($image), $this->getheightfromimage($image));
        return $newimage;
    }
    function actioncrop($cropleft, $cropright, $croptop, $cropbottom) {
        $cropwidth = $this->getwidth() - $cropleft - $cropright;
        $cropheight = $this->getheight() - $croptop - $cropbottom;
        $newimagecropped = @imagecreatetruecolor($cropwidth, $cropheight);
        pie_keeptranspacecycopyresampled($newimagecropped, $this->mimetype);
        //imagecopy($newimagecropped, $this->resourceworkwith, 0, 0, $cropleft, $croptop, $cropwidth, $cropheight);
        imagecopyresampled($newimagecropped, $this->resourceworkwith, 0, 0, $cropleft, $croptop, $cropwidth, $cropheight, $cropwidth, $cropheight);
        $this->resourceworkwith = $newimagecropped;
    }
    function actionundo() {
        $separatorpos = strrpos($this->actions, $this->actionseparatorsign);
        if (!($separatorpos === false)) {
            $this->actions = substr($this->actions, 0, $separatorpos);
        } else {
            $this->actions = "";
        }
    }
    function createimage($srcedit) {
        $info = getimagesize($srcedit);
        if (!$info)
            return null;
        $mimetype = image_type_to_mime_type($info[2]);
        if ($mimetype == image_type_to_mime_type(imagetype_jpeg)) {
            return imagecreatefromjpeg($srcedit);
        } else if ($mimetype == image_type_to_mime_type(imagetype_gif)) {
            return imagecreatefromgif($srcedit);
        } else if ($mimetype == image_type_to_mime_type(imagetype_png)) {
            return imagecreatefrompng($srcedit);
        }
        return null;
    }
    function actionrotate($degrees) {
        if (function_exists('imagerotate'))
            $this->resourceworkwith = imagerotate($this->resourceworkwith, $degrees, 0);
        else
            $this->resourceworkwith = pie_imagerotate($this->resourceworkwith, $degrees);
        if ($this->mimetype == image_type_to_mime_type(imagetype_gif) || $this->mimetype == image_type_to_mime_type(imagetype_png)) {
            //keep transparecy
            imagealphablending($this->resourceworkwith, true);
            imagesavealpha($this->resourceworkwith, true);
        }
    }
    function actiongrayscale() {
        if (function_exists('imagefilter'))
            imagefilter($this->resourceworkwith, img_filter_grayscale);
        else
            pie_grayscale($this->resourceworkwith);
    }
    function actioncontrast($contrast) {
        //-100 = max contrast, 0 = no change, +100 = min contrast
        if (function_exists('imagefilter'))
            imagefilter($this->resourceworkwith, img_filter_contrast, $contrast);
        else
            pie_contrast($this->resourceworkwith, $contrast);
    }
    function actionbrightness($light) {
        //-255 = min brightness, 0 = no change, +255 = max brightness
        if (function_exists('imagefilter'))
            imagefilter($this->resourceworkwith, img_filter_brightness, $light);
        else
            pie_brightness($this->resourceworkwith, $light);
    }
    function geterrormessages() {
        if (count($this->errormessages)) {
            pie_echo('

');
            pie_echo('
    ');
                foreach ($this->errormessages as $errormessage)
                    pie_echo('
  • ' . $errormessage . '
  • ');
                pie_echo("
");
            pie_echo('
');
        }
    }
    function getactions() {
        pie_echo($this->actions);
    }
    function getactionseparator() {
        if ($this->actions != "")
            return $this->actionseparatorsign;
        return "";
    }
    function saveimage($image, $tosrc, $mimetype = -1) {
        if ($mimetype == -1)
            $mimetype = $this->mimetype;
        if ($mimetype == image_type_to_mime_type(imagetype_jpeg)) {
            imagejpeg($image, $tosrc);
        } else if ($mimetype == image_type_to_mime_type(imagetype_gif)) {
            imagegif($image, $tosrc);
        } else if ($mimetype == image_type_to_mime_type(imagetype_png)) {
            //keep transparecy.
            imagesavealpha($image, true);
            imagepng($image, $tosrc);
        }
    }
    function cleanup() {
        if ($this->resourceworkwith)
            imagedestroy($this->resourceworkwith);
    }
    function rotatearray($numberofsteps, $arr) {
        $finalarray = array();
        //-3 to 3
        $finalarray[] = $arr[$this->numberofstepscalculator($numberofsteps + 0)];
        $finalarray[] = $arr[$this->numberofstepscalculator($numberofsteps + 1)];
        $finalarray[] = $arr[$this->numberofstepscalculator($numberofsteps + 2)];
        $finalarray[] = $arr[$this->numberofstepscalculator($numberofsteps + 3)];
        return $finalarray;
    }
    function numberofstepscalculator($sum) {
        $maxindex = 3;
        if ($sum > $maxindex)
            return ($sum - $maxindex) - 1;
        else if ($sum             return ($sum + $maxindex) + 1;
        }
        return $sum;
    }
    function adduseridtoimagesrc($imagesrc) {
        $name = end(explode(directory_separator, $imagesrc));
        $this->name = $name;
        $ext = end(explode('.', $name));
        $p = strlen($ext) + 1;
        $f = str_replace(substr($imagesrc, -$p), "{$this->userid}.{$ext}", $name);
        return $f;
    }
    function getformaction() {
        $joomlaisadmin = isset($_get['isadmin']) ? 'isadmin=' . $_get['isadmin'] . '&' : '';
        #return "index.php?".$joomlaisadmin.$this->httpimagekey."=".urlencode($this->srcedit);
        return "index.php?" . $joomlaisadmin . $this->httpimagekey . "=" . urlencode($this->name);
    }
    function getwidthkeepproportions() {
        return $this->widthkeepproportions;
    }
    function getheightkeepproportions() {
        return $this->heightkeepproportions;
    }
$ vim phpimageeditor/lite/shared/index.php
覆盖:
    ini_set('default_charset', 'utf-8');
   
header("cache-control: no-store");
header('content-type: text/html; charset: utf-8');
include 'lite/shared/config.php';
include 'lite/shared/includes/constants.php';
include 'lite/shared/includes/functions.php';
include 'lite/shared/classes/phpimageeditor.php';
global $objphpimageeditor;
$objphpimageeditor = new phpimageeditor();
    if (!$objphpimageeditor->isajaxpost) { ?>



php image editor
    <script type="text/javascript" src="lite/shared/javascript/jquery-1.7.1.min.js"></script>
    <script type="text/javascript" src="lite/shared/javascript/jquery.jcrop.js"></script>
        <script type="text/javascript" src="lite/shared/javascript/jquery.numeric.js"></script>
    <script type="text/javascript" src="lite/shared/javascript/jquery-ui-1.8.16.custom.min.js"></script>
       
        <script type="text/javascript" src="lite/shared/javascript/phpimageeditor.js"></script>
   
   
   
   
   
   

        <script type="text/javascript"><br>         var imagemaxwidth = <?php pie_echo(pie_image_max_width); ?>;<br>         var imagemaxheight = <?php pie_echo(pie_image_max_height); ?>;<br>         var imagewidth = <?php pie_echo($objphpimageeditor->getwidthfinal()); ?>;<br>         var imageheight = <?php pie_echo($objphpimageeditor->getheightfinal()); ?>;<br>         var textisrequired = "<?php pie_echo($objphpimageeditor->texts["is required"]); ?>";<br>         var textmustbenumeric = "<?php pie_echo($objphpimageeditor->texts["must be numeric"]); ?>";<br>         var textwidth = "<?php pie_echo($objphpimageeditor->texts["width"]); ?>";<br>         var textheight = "<?php pie_echo($objphpimageeditor->texts["height"]); ?>";<br>         var textnotnegative = "<?php pie_echo($objphpimageeditor->texts["not negative"]); ?>";<br>         var textnotinrange = "<?php pie_echo($objphpimageeditor->texts["not in range"]); ?>";<br>         var textcantbelargerthen = "<?php pie_echo($objphpimageeditor->texts["cant be larger then"]); ?>";<br>         var textanunexpectederror = "<?php pie_echo($objphpimageeditor->texts["an unexpected error"]); ?>";<br>         var brightness = <?php pie_echo($objphpimageeditor->inputbrightness); ?>;<br>         var contrast = <?php pie_echo($objphpimageeditor->inputcontrast); ?>;<br>         var brightnessmax = <?php pie_echo($objphpimageeditor->brightnessmax); ?>;<br>         var contrastmax = <?php pie_echo($objphpimageeditor->contrastmax); ?>;<br>            var formaction = "<?php pie_echo($objphpimageeditor->getformaction()); ?>";<br>            var formid = "<?php pie_echo($objphpimageeditor->formname); ?>";<br>            var actionupdate = "<?php pie_echo($objphpimageeditor->actionupdate); ?>";<br>            var actionundo = "<?php pie_echo($objphpimageeditor->actionundo); ?>";<br>            var actionsaveandclose = "<?php pie_echo($objphpimageeditor->actionsaveandclose); ?>";<br>            var actionrotateleft = "<?php pie_echo($objphpimageeditor->actionrotateleft); ?>";<br>            var actionrotateright = "<?php pie_echo($objphpimageeditor->actionrotateright); ?>";<br>            var actionsaveandclose = "<?php pie_echo($objphpimageeditor->actionsaveandclose); ?>";<br>            var menuresize = "<?php pie_echo(pie_menu_resize); ?>";<br>            var menurotate = "<?php pie_echo(pie_menu_rotate); ?>";<br>            var menucrop = "<?php pie_echo(pie_menu_crop); ?>";<br>            var menueffects = "<?php pie_echo(pie_menu_effects); ?>";<br>            var ajaxposttimeoutms = <?php pie_echo(pie_ajax_post_timeout_ms); ?>; <br>            var tid = <?php echo $tid?>;<br>            var pid = <?php echo $pid?>;<br>            var uid = <?php echo $uid?>;<br>            var imgname = "<?php echo $img?>";<br>            var pw = 375;<br>            var ph = 500;<br> </script>





errorhasoccurred()) { ?>



">

texts["resize image"]); ?>





">

texts["rotate image"]); ?>








">

texts["effects"]); ?>











                                                                               














inputkeepproportions ? 'checked="checked"' : ''); ?>/>





texts["instructions"]); ?>

texts["resize help"]); ?>



                                                       

相关文章

PHP速学教程(入门到精通)
PHP速学教程(入门到精通)

PHP怎么学习?PHP怎么入门?PHP在哪学?PHP怎么学才快?不用担心,这里为大家提供了PHP速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!

下载

本站声明:本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn

热门AI工具

更多
DeepSeek
DeepSeek

幻方量化公司旗下的开源大模型平台

豆包大模型
豆包大模型

字节跳动自主研发的一系列大型语言模型

通义千问
通义千问

阿里巴巴推出的全能AI助手

腾讯元宝
腾讯元宝

腾讯混元平台推出的AI助手

文心一言
文心一言

文心一言是百度开发的AI聊天机器人,通过对话可以生成各种形式的内容。

讯飞写作
讯飞写作

基于讯飞星火大模型的AI写作工具,可以快速生成新闻稿件、品宣文案、工作总结、心得体会等各种文文稿

即梦AI
即梦AI

一站式AI创作平台,免费AI图片和视频生成。

ChatGPT
ChatGPT

最最强大的AI聊天机器人程序,ChatGPT不单是聊天机器人,还能进行撰写邮件、视频脚本、文案、翻译、代码等任务。

相关专题

更多
pixiv网页版官网登录与阅读指南_pixiv官网直达入口与在线访问方法
pixiv网页版官网登录与阅读指南_pixiv官网直达入口与在线访问方法

本专题系统整理pixiv网页版官网入口及登录访问方式,涵盖官网登录页面直达路径、在线阅读入口及快速进入方法说明,帮助用户高效找到pixiv官方网站,实现便捷、安全的网页端浏览与账号登录体验。

928

2026.02.13

微博网页版主页入口与登录指南_官方网页端快速访问方法
微博网页版主页入口与登录指南_官方网页端快速访问方法

本专题系统整理微博网页版官方入口及网页端登录方式,涵盖首页直达地址、账号登录流程与常见访问问题说明,帮助用户快速找到微博官网主页,实现便捷、安全的网页端登录与内容浏览体验。

307

2026.02.13

Flutter跨平台开发与状态管理实战
Flutter跨平台开发与状态管理实战

本专题围绕Flutter框架展开,系统讲解跨平台UI构建原理与状态管理方案。内容涵盖Widget生命周期、路由管理、Provider与Bloc状态管理模式、网络请求封装及性能优化技巧。通过实战项目演示,帮助开发者构建流畅、可维护的跨平台移动应用。

183

2026.02.13

TypeScript工程化开发与Vite构建优化实践
TypeScript工程化开发与Vite构建优化实践

本专题面向前端开发者,深入讲解 TypeScript 类型系统与大型项目结构设计方法,并结合 Vite 构建工具优化前端工程化流程。内容包括模块化设计、类型声明管理、代码分割、热更新原理以及构建性能调优。通过完整项目示例,帮助开发者提升代码可维护性与开发效率。

29

2026.02.13

Redis高可用架构与分布式缓存实战
Redis高可用架构与分布式缓存实战

本专题围绕 Redis 在高并发系统中的应用展开,系统讲解主从复制、哨兵机制、Cluster 集群模式及数据分片原理。内容涵盖缓存穿透与雪崩解决方案、分布式锁实现、热点数据优化及持久化策略。通过真实业务场景演示,帮助开发者构建高可用、可扩展的分布式缓存系统。

103

2026.02.13

c语言 数据类型
c语言 数据类型

本专题整合了c语言数据类型相关内容,阅读专题下面的文章了解更多详细内容。

54

2026.02.12

雨课堂网页版登录入口与使用指南_官方在线教学平台访问方法
雨课堂网页版登录入口与使用指南_官方在线教学平台访问方法

本专题系统整理雨课堂网页版官方入口及在线登录方式,涵盖账号登录流程、官方直连入口及平台访问方法说明,帮助师生用户快速进入雨课堂在线教学平台,实现便捷、高效的课程学习与教学管理体验。

17

2026.02.12

豆包AI网页版入口与智能创作指南_官方在线写作与图片生成使用方法
豆包AI网页版入口与智能创作指南_官方在线写作与图片生成使用方法

本专题汇总豆包AI官方网页版入口及在线使用方式,涵盖智能写作工具、图片生成体验入口和官网登录方法,帮助用户快速直达豆包AI平台,高效完成文本创作与AI生图任务,实现便捷智能创作体验。

764

2026.02.12

PostgreSQL性能优化与索引调优实战
PostgreSQL性能优化与索引调优实战

本专题面向后端开发与数据库工程师,深入讲解 PostgreSQL 查询优化原理与索引机制。内容包括执行计划分析、常见索引类型对比、慢查询优化策略、事务隔离级别以及高并发场景下的性能调优技巧。通过实战案例解析,帮助开发者提升数据库响应速度与系统稳定性。

92

2026.02.12

热门下载

更多
网站特效
/
网站源码
/
网站素材
/
前端模板

精品课程

更多
相关推荐
/
热门推荐
/
最新课程
AngularJS教程
AngularJS教程

共24课时 | 3.8万人学习

CSS3实现按钮特效视频教程
CSS3实现按钮特效视频教程

共15课时 | 3.3万人学习

细说PHP第三季
细说PHP第三季

共58课时 | 11.5万人学习

关于我们 免责申明 举报中心 意见反馈 讲师合作 广告合作 最新更新
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送

Copyright 2014-2026 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号