Thursday, 23 February 2017

how to write TEXT on image in php

header ("Content-type: image/jpeg");

$string = "This is simple text";

$font = 20;

$width = imagefontwidth($font) * strlen($string) ;

$height = imagefontheight($font) ;

$im = imagecreatefromjpeg("manjeet.jpg");

$x = imagesx($im) - $width ;

$y = imagesy($im) - $height;

$backgroundColor = imagecolorallocate ($im, 255, 255, 255);

$textColor = imagecolorallocate ($im, 0, 0,0);

imagestring ($im, $font, $x, $y, $string, $textColor);

imagejpeg($im);

Wednesday, 15 February 2017

How to save image Bit Code folder and database in android REST API

create new file in php

parameter name : encoding_string

       header('Content-Type: bitmap; charset=utf-8');
        if($_POST['encoding_string']){
        
        $encoding_string=$_POST['encoding_string'];
        
        $image_name=time().'.jpg';
        
        $decode_string = base64_decode($encoding_string);
        
        $path = 'uploads/'.$image_name;
        
        $file= fopen($path,'wb');
        
        $is_written=fwrite($file, $decode_string);
        
        fclose($file);
        
        if($is_written > 0 ){
                                           success here ...........................
                                      }

}