How to add text on image in Laravel?

How to add text on image in Laravel?

In this post we will give you information about How to add text on image in Laravel?. Hear we will give you detail about How to add text on image in Laravel?And how to use it also give you demo for it if it is necessary.

if you are use laravel and you want to add text on image or resize, crop image then we can do with “intervention/image” pakacke.

you have to just follow few step and you can add text on image.

Step 1 : you have to add package on your laravel project by using composer like :

composer require intervention/image

Step 2 : then you have to add provider path and alias path in config/app.php file like :

In $provides :

'InterventionImageImageServiceProvider'

In $aliases :

'Image' => 'InterventionImageFacadesImage'


Step 3 : then you can use Image class in your controller function like this :

public function makeimage()

{

$img = Image::make(public_path('images/hardik.jpg'));

$img->text('This is a example ', 120, 100);

$img->save(public_path('images/hardik3.jpg'));

}

Now you can check image you find text in your image, if you also want to set font color, font size, font style then you can set this way :

public function makeimage()

{

$img = Image::make(public_path('images/hardik.jpg'));

$img->text('This is a example ', 120, 100, function($font) {

$font->file(public_path('path/font.ttf'));

$font->size(28);

$font->color('#e1e1e1');

$font->align('center');

$font->valign('bottom');

$font->angle(90);

});

$img->save(public_path('images/hardik3.jpg'));

}

Hope this code and post will helped you for implement How to add text on image in Laravel?. if you need any help or any feedback give it in comment section or you have good idea about this post you can give it comment section. Your comment will help us for help you more and improve us. we will give you this type of more interesting post in featured also so, For more interesting post and code Keep reading our blogs

For More Info See :: laravel And github

Leave a Comment

Your email address will not be published. Required fields are marked *

12  +    =  20

We're accepting well-written guest posts and this is a great opportunity to collaborate : Contact US