troubleshooting Question

php saving image script

Avatar of rivkamak
rivkamakFlag for United States of America asked on
Web DevelopmentPHPJoomla
15 Comments1 Solution629 ViewsLast Modified:
I have a script that I upload an image and crop it.
My script saves the original file as tmp in my folder.
After I crop it, I am having a problem that the final file only saves if  the original file is smaller than around 900kb.
I don't understand , because it wouldn't be a  folder setting because the temp file saves no matter how big it is.
just the final file.
I am pasted the code I have. Where does it specify the max file size here:
  public function process($saveToFilePath = null, $retainFileExt = false)
    {
	
//$saveToFilePath = 'http://'.$_SERVER['SERVER_NAME'].'/admin/crop/picture/';
        // list($width, $height) = getimagesize($_POST["imageSource"]);
        // $viewPortW = $_POST["viewPortW"];
        //$viewPortH = $_POST["viewPortH"];
        $pWidth = $_POST["imageW"];
        $pHeight = $_POST["imageH"];
        $ext = end(explode(".", $_POST["imageSource"]));	
				 		

        $function = $this->returnCorrectFunction($ext);
	
        $image = $function($_POST["imageSource"]);
        $width = imagesx($image);
        $height = imagesy($image);
    
	    // Resample
        $image_p = imagecreatetruecolor($pWidth, $pHeight);
        $this->setTransparency($image, $image_p, $ext);
        imagecopyresampled($image_p, $image, 0, 0, 0, 0, $pWidth, $pHeight, $width, $height);
        imagedestroy($image);
        $widthR = imagesx($image_p);
        $hegihtR = imagesy($image_p);
			

        $selectorX = $_POST["selectorX"];
        $selectorY = $_POST["selectorY"];
        if ($_POST["imageRotate"]) {
            $angle = 360 - $_POST["imageRotate"];
            $image_p = imagerotate($image_p, $angle, 0);

            $pWidth = imagesx($image_p);
            $pHeight = imagesy($image_p);

            //print $pWidth."---".$pHeight;

            $diffW = abs($pWidth - $widthR) / 2;
            $diffH = abs($pHeight - $hegihtR) / 2;

            $_POST["imageX"] = ($pWidth > $widthR ? $_POST["imageX"] - $diffW : $_POST["imageX"] + $diffW);
            $_POST["imageY"] = ($pHeight > $hegihtR ? $_POST["imageY"] - $diffH : $_POST["imageY"] + $diffH);


        }

        $dst_x = $src_x = $dst_y = $src_y = 0;

        if ($_POST["imageX"] > 0) {
            $dst_x = abs($_POST["imageX"]);
        } else {
            $src_x = abs($_POST["imageX"]);
        }
        if ($_POST["imageY"] > 0) {
            $dst_y = abs($_POST["imageY"]);
        } else {
            $src_y = abs($_POST["imageY"]);
        }

        $viewport = imagecreatetruecolor($_POST["viewPortW"], $_POST["viewPortH"]);
        $this->setTransparency($image_p, $viewport, $ext);

        imagecopy($viewport, $image_p, $dst_x, $dst_y, $src_x, $src_y, $pWidth, $pHeight);
        imagedestroy($image_p);
        $selector = imagecreatetruecolor($_POST["selectorW"], $_POST["selectorH"]);
        $this->setTransparency($viewport, $selector, $ext);
        $a = imagecopy($selector, $viewport, 0, 0, $selectorX, $selectorY, $_POST["viewPortW"], $_POST["viewPortH"]);
        $saveToFilePath = ($retainFileExt == true) ? $saveToFilePath . '.' . $ext : $saveToFilePath;

        $this->parseImage($ext, $selector, $saveToFilePath);
        imagedestroy($viewport);
        //Return value
        return $this;
        /* Functions */

    }
ASKER CERTIFIED SOLUTION
Join our community to see this answer!
Unlock 1 Answer and 15 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 15 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros