تقييم الموضوع :
  • 0 أصوات - بمعدل 0
  • 1
  • 2
  • 3
  • 4
  • 5
طلب اضافة ختم الصور لهذا الكود
#40
تعديل دالة AddWatermark

PHP كود :
function AddWatermark($imagePath$text) {

    $data = @file_get_contents($imagePath);
    if (!$data) return;

    $img = @imagecreatefromstring($data);

    if (!$img) {
        return; // لا تخرب الصورة إذا فشل
    }

    $width  imagesx($img);
    $height imagesy($img);

    $color imagecolorallocatealpha($img25525525550);

    $x $width 120;
    $y $height 15;

    imagestring($img3$x$y$text$color);

    imagejpeg($img$imagePath90);

    imagedestroy($img);


احتمال اخر اذا ما ضبط معك الاول 
PHP كود :
function AddWatermark($imagePath$text) {

    $ext strtolower(pathinfo($imagePathPATHINFO_EXTENSION));

    if ($ext == 'jpg' || $ext == 'jpeg') {
        $img = @imagecreatefromjpeg($imagePath);
    } elseif ($ext == 'png') {
        $img = @imagecreatefrompng($imagePath);
    } elseif ($ext == 'gif') {
        $img = @imagecreatefromgif($imagePath);
    } elseif ($ext == 'webp') {
        $img = @imagecreatefromwebp($imagePath);
    } else {
        return;
    }

    if (!$img) return;

    $width  imagesx($img);
    $height imagesy($img);

    $color imagecolorallocatealpha($img25525525550);

    $x $width 120;
    $y $height 15;

    imagestring($img3$x$y$text$color);

    if ($ext == 'jpg' || $ext == 'jpeg') {
        imagejpeg($img$imagePath90);
    } elseif ($ext == 'png') {
        imagepng($img$imagePath);
    } elseif ($ext == 'gif') {
        imagegif($img$imagePath);
    } elseif ($ext == 'webp') {
        imagewebp($img$imagePath);
    }

    imagedestroy($img);

[صورة مرفقة: 177461173141861.gif]
الرد }}}
تم الشكر بواسطة: nnnjk


الردود في هذا الموضوع
RE: طلب اضافة ختم الصور لهذا الكود - بواسطة Amir_Alzubidy - 04-04-26, 06:15 PM


التنقل السريع :


يقوم بقرائة الموضوع: