Search
 
SCRIPT & CODE EXAMPLE
 

PHP

upload image with watermark in codeigniter

        // Define it in configuration file. And call it
        // About configurations: https://codeigniter.com/user_guide/libraries/config.html
        $wm_font_size = 16; // Watermark height (font size) contains 16% of image 

        $this->load->library('upload');
        $this->load->library('image_lib');
        $config['image_library'] = 'GD2';

        for ($i = 0; $i < $number_of_files; $i++) {
                $_FILES['file']['name'] = $files['file']['name'][$i];
                $_FILES['file']['type'] = $files['file']['type'][$i];
                $_FILES['file']['tmp_name'] = $files['file']['tmp_name'][$i];
                $_FILES['file']['error'] = $files['file']['error'][$i];
                $_FILES['file']['size'] = $files['file']['size'][$i];
                $config['source_image'] = $files['file']['tmp_name'][$i];
                $config['wm_text'] = 'Copyright example.com';
                $config['wm_type'] = 'text';
                $config['wm_font_size'] = ceil($files['file'][image_height][$i]/100*wm_font_size);
                $config['wm_vrt_alignment'] = 'middle';
                $config['wm_hor_alignment'] = 'center';
                $this->image_lib->initialize($config);
                $this->image_lib->watermark();

                $config['source_image'] = $files['file']['tmp_name'][$i];
                $config['wm_overlay_path'] = './application/assets/images/example.png';
                $config['wm_type'] = 'overlay';
                $config['width'] = '50';
                $config['height'] = '50';
                $config['padding'] = '50';
                $config['wm_opacity'] = '100';
                $config['wm_vrt_alignment'] = 'bottom';
                $config['wm_hor_alignment'] = 'right';
                $config['wm_vrt_offset'] = '100';
                $this->image_lib->initialize($config);
                $this->image_lib->watermark();

                if (!$this->upload->do_upload("file")) {
                    $errors++;
                } 
Comment

PREVIOUS NEXT
Code Example
Php :: read input from user 
Php :: How to go back to the main page in php 
Php :: get current month laravel 
Php :: send email php form 
Php :: withcookie function in php 
Php :: php array sort 
Php :: php xpath get all image 
Php :: query log laravel 
Php :: submit form and show results on same page without refresh 
Php :: laravel route regex except 
Php :: find the next 7 date data in laravel eloquent 
Php :: laravel automatically encrypt model atribute 
Php :: php check string 
Php :: dependency injection php 
Php :: php artisan key:generate error 
Php :: laravel execute command arguments 
Php :: how to use concat in laravel 
Php :: test_input php 
Php :: getting routes in middleware laravel 
Php :: function to find the mod of a number in php 
Php :: how to run php on windows 
Php :: login as user in laravel from admin panel 
Php :: php array if 
Php :: laravel routing 
Php :: laravel relations find 
Php :: get firstwod php 
Php :: how to redirect back to admin page if user is not authenticated in laravel based on the guard 
Php :: php string remove last character 
Php :: Symfony Expected argument of type "string", "null" given 
Php :: Use the DebugBar like an array where keys are the collector names 
ADD CONTENT
Topic
Content
Source link
Name
2+5 =