CodeIgniter Forums
how to insert a verified logo and digital signature in the uploaded document - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forum-5.html)
+--- Forum: General Help (https://forum.codeigniter.com/forum-24.html)
+--- Thread: how to insert a verified logo and digital signature in the uploaded document (/thread-73089.html)



how to insert a verified logo and digital signature in the uploaded document - kvanaraj - 03-17-2019

I want to embed a verified logo and verified date in the text field to the uploaded document. Need some suggestion guys.


RE: how to insert a verified logo and digital signature in the uploaded document - InsiteFX - 03-18-2019

Is this something like what your talking about?

Creating a verified badge for users with php


RE: how to insert a verified logo and digital signature in the uploaded document - kvanaraj - 03-19-2019

(03-18-2019, 04:23 AM)InsiteFX Wrote: Is this something like what your talking about?

Creating a verified badge for users with php

but i want to save that image in folder and also db. How to embed the text 
Code:
if(isset($_FILES['image_file']))
{
    $max_size = 800; //max image size in Pixels
    $destination_folder = 'D:/Websites';
    $watermark_png_file = 'watermark.png'; //watermark png file
    
    $image_name = $_FILES['image_file']['name']; //file name
    $image_size = $_FILES['image_file']['size']; //file size
    $image_temp = $_FILES['image_file']['tmp_name']; //file temp
    $image_type = $_FILES['image_file']['type']; //file type

    switch(strtolower($image_type)){ //determine uploaded image type
            //Create new image from file
            case 'image/png':
                $image_resource =  imagecreatefrompng($image_temp);
                break;
            case 'image/gif':
                $image_resource =  imagecreatefromgif($image_temp);
                break;          
            case 'image/jpeg': case 'image/pjpeg':
                $image_resource = imagecreatefromjpeg($image_temp);
                break;
            default:
                $image_resource = false;
        }
    
    if($image_resource){
        //Copy and resize part of an image with resampling
        list($img_width, $img_height) = getimagesize($image_temp);
        
        //Construct a proportional size of new image
        $image_scale        = min($max_size / $img_width, $max_size / $img_height);
        $new_image_width    = ceil($image_scale * $img_width);
        $new_image_height   = ceil($image_scale * $img_height);
        $new_canvas         = imagecreatetruecolor($new_image_width , $new_image_height);
        $text_color = imagecolorallocate($new_canvas, 233, 14, 91);
        imagestring($new_canvas, 1, 5, 5,  'A Simple Text String', $text_color);

        if(imagecopyresampled($new_canvas, $image_resource , 0, 0,0, 0, $new_image_width, $new_image_height, $img_width, $img_height))
        {
            
            if(!is_dir($destination_folder)){
                mkdir($destination_folder);//create dir if it doesn't exist
            }
            
            //center watermark
            $watermark_left = ($new_image_width/2)-(2/2); //watermark left            
            $watermark_bottom = ($new_image_height/2)-(2/2); //watermark bottom

            $watermark = imagecreatefrompng($watermark_png_file); //watermark image
            imagecopy($new_canvas, $watermark, $watermark_left, $watermark_bottom, 0, 0, 160, 128); //merge image
            
            //output image direcly on the browser.
            header('Content-Type: image/jpeg');
            
            
            imagejpeg($new_canvas, NULL , 90);
            
            //Or Save image to the folder
            //imagejpeg($new_canvas, $destination_folder.'/'.$image_name , 90);
            
            //free up memory
            imagedestroy($new_canvas);
            imagedestroy($image_resource);
            die();
        }
    }
}



RE: how to insert a verified logo and digital signature in the uploaded document - InsiteFX - 03-19-2019

You can use the standard php directory and file methods to save the image to where you want.

For the database just save the url link to the image in the database table.


RE: how to insert a verified logo and digital signature in the uploaded document - Jorgen_121 - 03-22-2019

(03-18-2019, 04:23 AM)InsiteFX Wrote: Is this something like what your talking about?

Natural Nootropic

This was super helpful man, thanks a lot (I literally joined to post this comment).