Welcome Guest, Not a member yet? Register   Sign In
Image watermarking with image overlay support
#1
Sad 

Currently there is no support for image watermarking with image overlay in image manipulation class. Text overlay is not enough to cover most of the image watermarking needs.
Reply
#2

CI has not special methods for working with watermark  "on the box". But i created self library which works with images and also can create watermarks. For example this is bit of code of a library method for creating watermarks. You can use this code on your project.
PHP Code:
public function watermarkImagestring $file, array $config = [])
    {
        if ($this->_checkFileExists($filefalse) && !empty($config))
        {
            if ($this->_checkFileExists($config['wm_image'], false))
            {
                $file FCPATH $file;

                $fileType pathinfo($file,PATHINFO_EXTENSION);

                switch($fileType)
                {
                    case 'png':

                        $img imagecreatefrompng($file);

                        break;

                    case 'jpg':
                    case 'jpeg':
                    default:

                        $img imagecreatefromjpeg($file);

                        break;
                }

                $watermark imagecreatefrompng($config['wm_image']);

                imagealphablending($watermarkfalse);

                imagesavealpha($watermarktrue);

                $img_w imagesx($img);

                $img_h imagesy($img);

                $wtrmrk_w imagesx($watermark);

                $wtrmrk_h imagesy($watermark);

                $dst_x = ($img_w 2) - ($wtrmrk_w 2); // For centering the watermark on any image

                $dst_y = ($img_h 2) - ($wtrmrk_h 2); // For centering the watermark on any image

                imagecopy($img$watermark$dst_x$dst_y00$wtrmrk_w$wtrmrk_h);

                imagejpeg($img$file$config['wm_quality'] ?? 90);

                imagedestroy($img);

                imagedestroy($watermark);
            }
        }
    
Reply




Theme © iAndrew 2016 - Forum software by © MyBB