Skip to content

Instantly share code, notes, and snippets.

@zoparga
Created November 9, 2021 13:52
Show Gist options
  • Save zoparga/a3a9b579bc65155d13c65222fe6f10cc to your computer and use it in GitHub Desktop.
Save zoparga/a3a9b579bc65155d13c65222fe6f10cc to your computer and use it in GitHub Desktop.
Place multiple watermark on picture with a 45 degree
$divided_by = 4;
$watermark_text = "watermark text";
for ($i = 0; $i < $image_resize->getWidth(); $i = $i+($image_resize->getWidth()/$divided_by)) {
for ($j = 0; $j < $image_resize->getHeight(); $j = $j+($image_resize->getHeight()/$divided_by)) {
$image_resize->text($watermark_text, $i, $j, function ($font) use ($image_resize) {
$font->file(storage_path('fonts/DejaVuSans.ttf'));
$font->size(($image_resize->getHeight()/70));
$font->color(array(0, 0, 0, 0.2));
$font->align('center');
$font->valign('bottom');
$font->angle(45);
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment