-1

This is a generated image from fb.com/supportdigitalindia

How Can i create this kind of image . Can I Do it with PHP ?

I need the way to process this kind of images ..

Aniruddha Chakraborty
  • 1,849
  • 1
  • 20
  • 32

1 Answers1

1

You can use imagecopymerge() like:

function overlay($img_a, $img_b, $alpha, $output)
{
    $canvas_a = imagecreatefromjpeg($img_a);
    $canvas_b = imagecreatefromjpeg($img_b);

    list($over_w, $over_h) = getimagesize($img_a);
    list($out_w, $out_h) = getimagesize($img_b);

    imagecopymerge(
        $canvas_b,               // Dest
        $canvas_a,               // Src
        0,                       // dst_x
        0,                       // dst_y
        (($over_w-$out_w)/2),    // src_x
        (($over_h-$out_h)/2),    // src_y
        $out_w,                  // src_w
        $out_h,                  // src_h
        100*$alpha               // pct
    );

    imagejpeg($canvas_b, $output, 100);
}

overlay('x.jpg', 'y.jpg', 0.6, 'z.jpg');

This will overlay img_1 on top of img_2 with the alpha specified.

Omran Jamal
  • 379
  • 5
  • 12