I'm using Imagemagick to dynamic generating an OpenGraph Image.
I'm processing that image step by step, means:
- Resize the image to 1200px width
- Grayscale the image
- Make image transparent
- Multiply the transparent image with the filter color
After creating the background image I'm starting to add the elements.
- Adding the Mainline
- -> 8. Adding some other elements
Unfortunately after generating that image there are some strange fragments around the text and the images I overlaid.
Any Idea how to avoid this?
I attached some images to demonstrate the problem.
EDIT:
I hope this helps
$imagename = uniqid() . ".jpg";
$image = $og_upload_path . '/' . $imagename;
$alpha = 15
$filterColor = "#08e2dd"; // Light Blue
// Asset images for processing the opengraph image
$white_background = $image_path . "/white.png";
$src_image = [Link to src image see above];
// Resize Image to 1200px width
system("convert '" . $src_image . "' -resize 1200 '" . $image . "'");
// Grayscale Image
system("convert '" . $image . "' -colorspace Gray '" . $image . "'");
// Make image transparent
system("composite -blend " . $alpha . " '" . $image . "' '" . $white_background . "' '" . $image . "'");
// Multiply Image with filter color
system("convert '" . $image . "' \ "
. " \( -clone 0 -fill '" . $filterColor . "' -colorize 100 \) \ "
. " -compose multiply \ "
. " -composite '" . $image . "'"
);
// Add MainLine Text
system("convert '" . $image . "' -size 1000x -background transparent \ "
. " -fill '" . $textColor_MainLine . "' \ "
. " -pointsize " . $fontSize_MainLine . " \ "
. " -font " . $path_fontfile . " \ "
. " -gravity center caption:" . $text_MainLine . " \ "
. " -gravity center -composite '" . $image . "'"
);