php උදව්වක් ඕනේ

Casinoboy

Well-known member
  • Jun 6, 2011
    5,244
    2,682
    113
    මචන්ලා PNG ෆයිල් දෙකක් එක ඉමේජ් එකකට සෙට් කරන්නේ කොහොමද?
    Facebook Proile Frame වගේ PHP walin
     

    dasuneranda

    Well-known member
  • Aug 24, 2011
    686
    691
    93
    දූපතේ
    to do this kind of work, you need to use GD library or ImageMagic

    this code work with GD library

    $photo_to_paste="image_to_paste.jpg"; //image 321 x 400
    $white_image="white_image.jpg"; //873 x 622

    $im = imagecreatefromjpeg($white_image);
    $condicion = GetImageSize($photo_to_paste); // image format?

    if($condicion[2] == 1) //gif
    $im2 = imagecreatefromgif("$photo_to_paste");
    if($condicion[2] == 2) //jpg
    $im2 = imagecreatefromjpeg("$photo_to_paste");
    if($condicion[2] == 3) //png
    $im2 = imagecreatefrompng("$photo_to_paste");

    imagecopy($im, $im2, (imagesx($im)/2)-(imagesx($im2)/2), (imagesy($im)/2)-(imagesy($im2)/2), 0, 0, imagesx($im2), imagesy($im2));

    imagejpeg($im,"test4.jpg",90);
    imagedestroy($im);
    imagedestroy($im2);
     

    Casinoboy

    Well-known member
  • Jun 6, 2011
    5,244
    2,682
    113
    to do this kind of work, you need to use GD library or ImageMagic

    this code work with GD library

    $photo_to_paste="image_to_paste.jpg"; //image 321 x 400
    $white_image="white_image.jpg"; //873 x 622

    $im = imagecreatefromjpeg($white_image);
    $condicion = GetImageSize($photo_to_paste); // image format?

    if($condicion[2] == 1) //gif
    $im2 = imagecreatefromgif("$photo_to_paste");
    if($condicion[2] == 2) //jpg
    $im2 = imagecreatefromjpeg("$photo_to_paste");
    if($condicion[2] == 3) //png
    $im2 = imagecreatefrompng("$photo_to_paste");

    imagecopy($im, $im2, (imagesx($im)/2)-(imagesx($im2)/2), (imagesy($im)/2)-(imagesy($im2)/2), 0, 0, imagesx($im2), imagesy($im2));

    imagejpeg($im,"test4.jpg",90);
    imagedestroy($im);
    imagedestroy($im2);

    macho easy widiyak nedda