PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Monday, October 10, 2022

[FIXED] What kind of image processing facebook using in http://fb.com/supportdigitalindia

 October 10, 2022     gd, image-processing, php     No comments   

Issue

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 ..


Solution

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.



Answered By - Omran Jamal
Answer Checked By - Clifford M. (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing