• 10-08-2019, 02:01:35
    #1
    Merhaba arkadaşlar, PHP ile basit bir olay paylaşmak istedim. Geliştirmek isteyenler olabilir.

    <?php
        header('Content-type: image/png');
        // GUNCELLEMEK İSTEDİĞİNİZ FOTOĞRAFIN LİNKİ.
        $filepath = 'resim_linki.jpg';
        $type = exif_imagetype($filepath); 
    
        $allowedTypes = array(
            1,  // [] gif
            2,  // [] jpg
            3,  // [] png
            6   // [] bmp
        );
        if (!in_array($type, $allowedTypes)) {
            return false;
        }
        switch ($type) {
            case 1 :
                $im = imageCreateFromGif($filepath);
                break;
            case 2 :
                $im = imageCreateFromJpeg($filepath);
                break;
            case 3 :
                $im = imageCreateFromPng($filepath);
                break;
            case 6 :
                $im = imageCreateFromBmp($filepath);
                break;
        }
    
    
        imageflip($im, IMG_FLIP_HORIZONTAL);
        // EKLEYECEĞİNİZ WATERMARK RESMİ. AYNI İSİMDE DOSYAYI DEĞİŞTİRİN .PNG UZANTILI OLMALI.
        
        $stamp = imagecreatefrompng('watermark.png');
    
        $marge_right = 10;
        $marge_bottom = 10;
        $sx = imagesx($stamp);
        $sy = imagesy($stamp);
    
        imagecopy(
            $im,
            $stamp,
            imagesx($im) - $sx - $marge_right,
            imagesy($im) - $sy - $marge_bottom,
            0,
            0,
            imagesx($stamp),
            imagesy($stamp)
        );
        
    
        
        header('Content-type: image/png');
        
        imagejpeg($im);
        imagedestroy($im);
    
    ?>
  • 10-08-2019, 09:05:40
    #2
    Yararlı bir paylaşım olsun. Teşekkürler