Take the 2-minute tour ×

i have a function that saves my picture to disk:

public function uploadToDiskMulty($folderPath, $filename)
    // create the transfer adapter
    // note that setDestiation is deprecated, instead use the Rename filter
    $adapter = new Zend_File_Transfer_Adapter_Http();
    $adapter->addFilter('Rename', array(
            'target'    => $filename,
            'overwrite' => true

    // try to receive one file
    if ($adapter->receive($folderPath)) {
        $message = "success";
    } else {
        $message = "fail";

    return $message;

then i have a function that crops a image

public function uploadCroppedImage($image, $x, $y, $w, $h)
    $targ_w = 200;
    $targ_h = 300;
    $jpeg_quality = 90;

    $img_r = imagecreatefromstring(file_get_contents($image));
    $dst_r = ImageCreateTrueColor( $targ_w, $targ_h );

    imagecopyresampled($dst_r, $img_r, 0, 0, $x, $y, $targ_w, $targ_h, $w, $h);

the $image = http://test.com/test_folder/example.jpg

the $folderPath = /var/www/media/test_folder/

and the $filename = example.jpg

my issue is that i need the cropped image path so i can run it through the uploadToDiskMulty function.

imagecopyresampled returns true or false.

any ideas?


share|improve this question
add comment

1 Answer

up vote 0 down vote accepted

You can output it with imagejpeg(), or equivalent for the type you need.

imagejpeg($dst_r, 'somepath/someimg.jpg');
share|improve this answer
does it saves it? what if i pass my server path /var/www/media/... –  Patrioticcow Apr 16 '12 at 20:46
You can use any path you want. –  Brad Apr 16 '12 at 20:46
hmmm, i have this imagejpeg($dst_r, $image, 90); but it doesn't seem to overwrite the original file –  Patrioticcow Apr 16 '12 at 20:52
i did it, i have to pass the server path. lots of thanks –  Patrioticcow Apr 16 '12 at 20:56
add comment

Your Answer


