• 05-01-2014, 00:56:15
    #1
    Arkadaşlar merhaba, elimde resim boyutlandırmak için bir script var. bu script ile istediğim boyutlarda resmi oluşturuyorum ancak watermark resmini çekmiyor.

    Script aşağıda, eklemek istediğim şey şu: aşağıdaki iki satırla orjinal resmi boyutlandırıyor, bunu kendim ekledim. bunu eklemeden önce watermark görünüyordu; fakat boyutlandırma yapamıyordum.
    $thumbImg = imagecreatetruecolor($w, $h);
      imagecopyresampled($thumbImg, $image, 0, 0, 0, 0, $w, $h, imagesx($image), imagesy($image));
    Script bu:
    <?php
    
    /*
     * This script places a watermark on a given jpeg, png or gif image.
     *
     * Use the script as follows in your HTML code:
     * <img src="watermark.php?image=image.jpg&watermark=watermark.png" />
     *
     * Visit http://www.htmlguard.com for more great scripts!
     */
    
      // loads a png, jpeg or gif image from the given file name
      function imagecreatefromfile($image_path) {
        // retrieve the type of the provided image file
        list($width, $height, $image_type) = getimagesize($image_path);
    
        // select the appropriate imagecreatefrom* function based on the determined
        // image type
        switch ($image_type)
        {
          case IMAGETYPE_GIF: return imagecreatefromgif($image_path); break;
          case IMAGETYPE_JPEG: return imagecreatefromjpeg($image_path); break;
          case IMAGETYPE_PNG: return imagecreatefrompng($image_path); break;
          default: return ''; break;
        }
      }
    
      // load source image to memory
      $image = imagecreatefromfile($_GET['p']);
      $w = intval($_GET['w']);
      $h = intval($_GET['h']);
      if (!$image) die('Unable to open image');
      $thumbImg = imagecreatetruecolor($w, $h);
      imagecopyresampled($thumbImg, $image, 0, 0, 0, 0, $w, $h, imagesx($image), imagesy($image));
    
      // load watermark to memory
      $watermark = imagecreatefromfile('images/watermark.png');
      if (!$image) die('Unable to open watermark');
    
      // calculate the position of the watermark in the output image (the
      // watermark shall be placed in the lower right corner)
      //$watermark_pos_x = (imagesx($thumbImg) - imagesx($watermark)) / 2;
      //$watermark_pos_y = (imagesy($thumbImg) - imagesy($watermark)) / 2;
    
      // merge the source image and the watermark
      imagecopy($thumbImg, $watermark,  0, 0, $w, $h,imagesx($watermark), imagesy($watermark));
    
      // output watermarked image to browser
      header('Content-Type: image/jpeg');
      imagejpeg($thumbImg, '', 80);  // use best image quality (100)
    
      // remove the images from memory
      imagedestroy($image);
      imagedestroy($watermark);
    
    ?>
  • 09-01-2014, 14:24:01
    #2
    Arkadaşlar, yardımcı olabilecek kimse yokmu ?