Php with 2 images merge problem

Discussion in 'PHP' started by erkin0007, Jun 8, 2013.

  1. #1
    hi guys.i am from turkey.my engilish is bad,sorry

    this code is ,
    take in 2 images and merge
    but it is not working. my errors are;
    ---------------------------------------------------------------------------------------------

    Warning: imagecreatefromjpeg() [function.imagecreatefromjpeg]: gd-jpeg: JPEG library reports unrecoverable error: in C:\AppServ\www\index2.php on line 4

    Warning: imagecreatefromjpeg() [function.imagecreatefromjpeg]: 'resimler/rsmpu.jpeg' is not a valid JPEG file in C:\AppServ\www\index2.php on line 4

    Warning: imagesx(): supplied argument is not a valid Image resource in C:\AppServ\www\index2.php on line 15

    Warning: imagesy(): supplied argument is not a valid Image resource in C:\AppServ\www\index2.php on line 16

    Warning: imagecopy(): supplied argument is not a valid Image resource in C:\AppServ\www\index2.php on line 17

    Warning: imagejpeg(): supplied argument is not a valid Image resource in C:\AppServ\www\index2.php on line 22

    Warning: imagedestroy(): supplied argument is not a valid Image resource in C:\AppServ\www\index2.php on line 23
    -----------------------------------------------------------------------------------------------------------------------------------



    <?php
    ob_start();
    $damga = imagecreatefromjpeg('resimler/pu.jpeg');
    $foto = imagecreatefromjpeg('resimler/rsmpu.jpeg');
     
    // Damganın kenar boşluklarını ayarlayıp resmin
    // yükseklik ve genişliğini alalım
    $sağ_boşluk = 10;
    $alt_boşluk = 10;
    $sx = imagesx($damga);
    $sy = imagesy($damga);
     
    // Damga resmini koordinatları belirterek kenar boşlukları ile
    // birlikte fotoğrafın üzerine kopyalayalım.
    imagecopy($foto, $damga, imagesx($foto) - $sx - $sağ_boşluk,
                            imagesy($foto) - $sy - $alt_boşluk,
                            0, 0, imagesx($damga), imagesy($damga));
     
    // Sonucu çıktılayıp belleği serbest bırakalım.
     
    //header("Content-type: image/jpeg");
    imagejpeg($foto,"resimler/resimyuklemebasarili.jpg");
    imagedestroy($foto);
    ob_end_flush();
    ?>
    PHP:
     
    erkin0007, Jun 8, 2013 IP
  2. sorindsd

    sorindsd Well-Known Member

    Messages:
    201
    Likes Received:
    3
    Best Answers:
    2
    Trophy Points:
    118
    #2
    something is wrong with rsmpu.jpeg file... you should recreate it.
     
    sorindsd, Jun 8, 2013 IP
  3. aidanriley629

    aidanriley629 Banned

    Messages:
    429
    Likes Received:
    23
    Best Answers:
    3
    Trophy Points:
    175
    #3
    Yes, it looks like that jpeg is corrupt, or should be a different file format.
     
    aidanriley629, Jun 8, 2013 IP
  4. ogah

    ogah Member

    Messages:
    60
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    36
    #4
    try adding
    error_reporting(0);
    PHP:
    before ob start
    and make sure the image files are afailable. and the name n ext of image maybe case sensitive
     
    ogah, Jun 9, 2013 IP
  5. erkin0007

    erkin0007 Member

    Messages:
    27
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    41
    #5
    i passed to this exam
     
    erkin0007, Jun 9, 2013 IP