Topic: [HELP] Do more when uploading image

I wish to do more processes when uploading the image, such as resize the image into different size (for thumbnail purpose), and add a watermark to the image.

How can i do this? I found that the upload.php is not really working, i delete the file and the upload process is still working.

Any idea??

Many Thanks.

Re: [HELP] Do more when uploading image

we have a library installed on the php server to create thumbnails.

can't remember what it is called. but here is my code:

function createthumb($name,$filename,$new_w,$new_h)
    {
        $system=explode(".",$name);
        if (preg_match("/jpg|jpeg|JPG|JPEG/",$system[1])){
            $src_img=imagecreatefromjpeg($name);
        }
        if (preg_match("/png|PNG/",$system[1])){$src_img=imagecreatefrompng($name);}
        $old_x=imageSX($src_img);
        $old_y=imageSY($src_img);
        
        $dst_img=ImageCreateTrueColor($new_w,$new_h);
        imagecopyresampled($dst_img,$src_img,0,0,0,0,$new_w,$new_h,$old_x,$old_y); 
        imagejpeg($dst_img,$filename); 
        imagedestroy($dst_img); 
        imagedestroy($src_img); 
    }

This works well for us.

Re: [HELP] Do more when uploading image

Adding watermarks onto images is not currently supported. You could write some post-upload server side script that does that. And while the same is true for resize feature as well, Plupload in fact can resize images before it uploads them. What kind of problem do you got with resizing? You do not know how to initiate it? Or you pass resize parameters (can be found here) and they do not work as expected?

Please provide additional details, so that we could better help you out.

If you want to see your issue fixed, do not report it here, do it on - GitHub.

Re: [HELP] Do more when uploading image

Thanks for the reply, i have solved the problem. I edited the upload.php. I include a third party library (class.upload.php) to help me handle all the images processes, such as resize into 3 different size and keep the original size, add watermark, rename the file and etc.
Actually it is quite straight forward, but I need to combine them with Cakephp, therefore i need to make some changes.

Btw, how to display the error message on the uploader? it always display a tick (success) if the requested page (upload.php) was found.

E.g

die('{"jsonrpc" : "2.0", "error" : {"code": 101, "message": "Failed to open input stream."}, "id" : "id"}');

I check the JSON response by Firebug and the correct message is returned, but, in the uploader, it still show 100% uploaded and the green tick icon.

Re: [HELP] Do more when uploading image

I agree, not showing errors when possible is not a good thing. I'm revising both widgets now and will include the fix for this too. Thank you.

If you want to see your issue fixed, do not report it here, do it on - GitHub.