2

I am using the image/Intervention package to write a text (as a watermark) on an image. Now, I want the text to have a background color with a distinct shape. I want something like this.

enter image description here

This is what I am doing currently

$code = 7025;

if ($request->file) {
    $i = 1;
    foreach ($request->file as $photo) {
        $i++;
        $file = $photo;
        $img = Image::make($file);
        $height = $img->height();
        $width = $img->width();

        $aHeight = 10 * $height / 100;
        $aWidth = 90 * $width / 100;

        $img->text($code, $aWidth, $aHeight, function ($font) {
            $font->file(public_path('font1.ttf'));
            $font->size(45);
            $font->color('#d90f0f');
            $font->align('right');
            $font->valign('top');
        });
        $img_url = $code + $i;
        $img->save(public_path('images/'.$img_url.'.jpg'));
    }
}

Please how do I accomplish this background color and shape?

Karl Hill
  • 12,937
  • 5
  • 58
  • 95
shekwo
  • 1,411
  • 1
  • 20
  • 50

0 Answers0