(non-PHPdoc)
@see \vxPHP\Image\ImageModifier::do_watermark()
338133
protected function do_watermark(\stdClass $src, $watermarkFile) {

		$stamp			= imagecreatefrompng($watermarkFile);
		$stampWidth		= imagesx($stamp);
		$stampHeight	= imagesy($stamp);

		$dst = new \stdClass();
		$dst->resource	= imagecreatetruecolor($src->width, $src->height);
		$dst->width		= $src->width;
		$dst->height	= $src->height;

		// stamp is centered onto source image, opacity 50%
		imagecopy($dst->resource, $src->resource, 0, 0, 0, 0, $src->width, $src->height);

		$this->imagecopymerge_alpha(
			$dst->resource,
			$stamp,
			($src->width - $stampWidth) / 2,
			($src->height - $stampHeight) / 2,
			0, 0,
			$stampWidth,
			$stampHeight,
			100
		);

		return $dst;
	}
449341
private function watermark(array $params)
    {
        if (isset($params['posX']) && is_numeric($params['posX'])) {
            $posX = $params['posX'];
        } else {
            $posX = null;
        }

        if (isset($params['posY']) && is_numeric($params['posY'])) {
            $posY = $params['posY'];
        } else {
            $posY = null;
        }

        if (is_null($posX) || is_null($posY)) {
            throw new Exception('Wrong watermark coordinates');
        }

        if (isset($params['width']) && is_numeric($params['width'])) {
            $width = $params['width'];
        } else {
            $width = 0;
        }

        if (isset($params['height']) && is_numeric($params['height'])) {
            $height = $params['height'];
        } else {
            $height = 0;
        }

        $mode = isset($params['mode']) ? $params['mode'] : self::THUMBNAIL_OUTBOUND;

        if (isset($params['image']) && file_exists(Yii::getAlias($params['image']))) {
            $watermarkPath = Yii::getAlias($params['image']);
        } else {
            $watermarkPath = null;
        }

        if (is_null($watermarkPath)) {
            throw new Exception('Incorrect watermark image path');
        }

        $watermark = Image::getImagine()->open($watermarkPath);

        if ($this->image->getSize()->getHeight() < $posY + $watermark->getSize()->getHeight() ||
            $this->image->getSize()->getWidth() < $posX + $watermark->getSize()->getWidth()
        ) {
            throw new Exception('Cannot paste watermark of the given size at the specified position, as it moves outside of the image\'s box');
        }

        if ($width > 0 && $height > 0) {
            $height = $this->image->getSize()->getHeight();
            $width = $this->image->getSize()->getWidth();

            $watermark = $watermark->thumbnail(new Box($width, $height), $mode);
        }

        if ($posX < 0) {
            $posX = $this->image->getSize()->getWidth() - abs($posX) - $watermark->getSize()->getWidth();
        }

        if ($posY < 0) {
            $posY = $this->image->getSize()->getHeight() - abs($posY) - $watermark->getSize()->getHeight();
        }

        $position = new Point($posX, $posY);

        $this->image->paste($watermark, $position);
    }
992791
public function setCorePhpthumbNooffsitelinkWatermarkSrc($value)
    {
        $this->setFieldName('phpthumb_nooffsitelink_watermark_src');
        $this->loadObject(true);
        $this->setFieldValue($value);

        return $this;
    }
468069
protected function perform()
    {
        $image = $this->imagine->open($this->file->path());

        if ( ! ($watermark = $this->getWatermarkImage())) {
            return false;
        }


        $imageSize     = $image->getSize();
        $watermarkSize = $watermark->getSize();

        // Calculate the placement of the watermark (we're aiming for the bottom right corner here).


        // Place the image in the correct position
        switch ($this->getWatermarkPosition()) {

            case 'top-left':
                $position = new \Imagine\Image\Point(0, 0);
                break;

            case 'top-right':
                $position = new \Imagine\Image\Point(
                    $imageSize->getWidth() - $watermarkSize->getWidth(),
                    0
                );
                break;

            case 'bottom-left':
                $position = new \Imagine\Image\Point(
                    0,
                    $imageSize->getHeight() - $watermarkSize->getHeight()
                );
                break;

            case 'center';
                $position = new \Imagine\Image\Point(
                    ((int) round($imageSize->getWidth() / 2)) - ((int) round($watermarkSize->getWidth() / 2)),
                    ((int) round($imageSize->getHeight() / 2)) - ((int) round($watermarkSize->getHeight() / 2))
                );
                break;

            case 'bottom-right':
            default:
                $position = new \Imagine\Image\Point(
                    $imageSize->getWidth() - $watermarkSize->getWidth(),
                    $imageSize->getHeight() - $watermarkSize->getHeight()
                );
        }

        $image->paste($watermark, $position);
        $image->save();

        return true;
    }
243142
public function markImage ( $imageResource) {
		if (!$this->stampImage) {
			$this->errorMsg="Stamp image is not set.";
			return(false);
		}
		$imageWidth  = imagesx( $imageResource);
		$imageHeight = imagesy( $imageResource);

		//set position of logo
		switch ($this->stampPositionX) {
			case transparentWatermarkOnLeft: 
			$leftStamp=0;
			break;
			case transparentWatermarkOnCenter:
			$leftStamp=($imageWidth - $this->stampWidth)/2;
			break;
			case transparentWatermarkOnRight:
			$leftStamp=$imageWidth - $this->stampWidth;
			break;
			default :
			$leftStamp=0;
		}
		switch ($this->stampPositionY) {
			case transparentWatermarkOnTop:
			$topStamp=0;
			break;
			case transparentWatermarkOnMiddle:
			$topStamp=($imageHeight - $this->stampHeight)/2;
			break;
			case transparentWatermarkOnBottom:
			$topStamp=$imageHeight - $this->stampHeight;
			break;
			default:
			$topStamp=0;
		}
		
		// for each pixel of stamp
		for ($x=0; $x<$this->stampWidth; $x++) {
			if (($x+$leftStamp<0)||($x+$leftStamp>=$imageWidth)) continue;
			for ($y=0; $y<$this->stampHeight; $y++) {
				if (($y+$topStamp<0)||($y+$topStamp>=$imageHeight)) continue;
				
				// search RGB values of stamp image pixel
				$indexStamp=ImageColorAt($this->stampImage, $x, $y);
				$rgbStamp=imagecolorsforindex ( $this->stampImage, $indexStamp);

				
				// search RGB values of image pixel
				$indexImage=ImageColorAt( $imageResource, $x+$leftStamp, $y+$topStamp);
				$rgbImage=imagecolorsforindex ( $imageResource, $indexImage);

				$randomizer=0;
				
				// compute new values of colors pixel
				$r=max( min($rgbImage["red"]+$rgbStamp["red"]-0x80, 0xFF), 0x00);
				$g=max( min($rgbImage["green"]+$rgbStamp["green"]-0x80, 0xFF), 0x00);
				$b=max( min($rgbImage["blue"]+$rgbStamp["blue"]-0x80, 0xFF), 0x00);
				
				// change  image pixel
				imagesetpixel ( $imageResource, $x+$leftStamp, $y+$topStamp, ($r<<16)+($g<<8)+$b);
			}
		}
	}
1023867
def watermark(self, image, options):
        
        watermark_img = options.get("watermark", settings.THUMBNAIL_WATERMARK)
        if not watermark_img:
            raise AttributeError("No THUMBNAIL_WATERMARK defined or set on tag.")
        watermark_path = find(watermark_img)
        if not watermark_path:
            raise RuntimeError("Could not find the configured watermark file.")
        if not os.path.isfile(watermark_path):
            raise RuntimeError("Set watermark does not point to a file.")

        if "cropbox" not in options:
            options["cropbox"] = None
        if "watermark_alpha" not in options:
            options["watermark_alpha"] = settings.THUMBNAIL_WATERMARK_OPACITY

        mark_sizes = options.get("watermark_size", settings.THUMBNAIL_WATERMARK_SIZE)
        if mark_sizes:
            try:
                options["watermark_size"] = parse_geometry(
                    mark_sizes, self.get_image_ratio(image, options)
                )
            except TypeError as e:
                raise TypeError(
                    "Please, update sorl-thumbnail package version to  >= 11.12b. %s"
                    % e
                )
        else:
            options["watermark_size"] = False

        if "watermark_pos" not in options:
            options["watermark_pos"] = settings.THUMBNAIL_WATERMARK_POSITION

        return self._watermark(
            image,
            watermark_path,
            options["watermark_alpha"],
            options["watermark_size"],
            options["watermark_pos"],
        )
498967
public function createWatermark(PHPThumb $watermarkThumb, array $position = [0, 0], $scale = .5)
    {
        return new Plugins\Watermark($watermarkThumb, $position, $scale);
    }
843131
function addWatermark(source, options, callback) {
    var error;

    // check for valid/invalid arguments
    if((arguments.length < 2)
        || (arguments.length  === 2 && !ratify.isFunction(arguments[1]))
        || (arguments.length > 2 && !ratify.isFunction(arguments[2]))) {
        throw new Error('Text-Watermark::addWatermark : Invalid arguments');
    }
    else if(arguments.length === 2 && ratify.isFunction(arguments[1])) {
        callback = arguments[1];
        options = null;
    }

    // if no image source is found
    if(!source || source == "") {
        error = new Error('Text-Watermark::addWatermark : No image source');
        return callback(error);
    }

    // check if source file exists at the specified path
    fs.lstat(source, function(err, stats) {
        if(err) {
            error = new Error('Text-Watermark::addWatermark : Image file doesn\'t exist at source ' + source);
            return callback(error);
        }
        else if(!stats.isFile()) {
            error = new Error('Text-Watermark::addWatermark : Invalid image source at ' + source);
            return callback(error);
        }
        else {
            // use default options if options aren't properly specified
            if(!options || typeof options !== 'object')
                options = defaultOptions;

            im.identify(source, function(err, imageData) {
                if(err) {
                    error = new Error('Text-Watermark::addWatermark : Error while processing image file : ' + err);
                    return callback(error);
                }

                var finalObj = _parseOptions(imageData, source, options);

                im.convert(finalObj.args, function(err, stdout) {
                    if(err) {
                        error = new Error('Text-Watermark::addWatermark : Error in applying watermark : ' + err);
                        return callback(error);
                    }
                    else {
                        console.log('Text-Watermark::addWatermark : Watermark applied. You can check the output file at : ' + finalObj.outputPath);
                        return callback(null);
                    }
                });
            });
        }
    });

    return;
}
26664
public function watermark($file, $offsetX = 0, $offsetY = 0, $opacity = 1.0)
    {
        $this->do_watermark($file, $offsetX, $offsetY, $opacity);

        return $this;
    }
755384
public function watermark(String $source, String $align = NULL, $margin = 0) : Thumb
    {
        $this->sets['watermark'] = [$source, $align, $margin]; 

        return $this;
    }
714652
public function execute($image)
    {
        $source = $this->argument(0)->required()->value();
        $position = $this->argument(1)->type('string')->value();
        $x = $this->argument(2)->type('digit')->value(0);
        $y = $this->argument(3)->type('digit')->value(0);

        // build watermark
        $watermark = $image->getDriver()->init($source);

        // define insertion point
        $image_size = $image->getSize()->align($position, $x, $y);
        $watermark_size = $watermark->getSize()->align($position);
        $target = $image_size->relativePosition($watermark_size);

        // insert image at position
        imagealphablending($image->getCore(), true);
        return imagecopy($image->getCore(), $watermark->getCore(), $target->x, $target->y, 0, 0, $watermark_size->width, $watermark_size->height);
    }
689629
public function assignWatermark(Request $request)
    {
        $getWatermak = $this->getWatermak();

        if(!$getWatermak) {
            return $getWatermak;
        }

        // go through each select image
        foreach ($request->all() as $key => $file){
            $image = new Media($file);

            // check if user has permissions to access this link
            if(!User::hasAccess('Media', 'update', $image->mediaID, true)) {
                return $this->noPermission();
            }

            if ($image->type == "image") {

                // mark original image
                $url = strpos($image->url, '?');
                if($url == false) {
                    $url = base_path($image->url);
                }else{
                    $url = base_path(explode('?', $image->url)[0]);
                }

                // does file exist
                if(!File::exists($url)) {
                    throw new \Exception("Original images ".$url." doesn't exists.");
                }

                $originalImage = Image::make($url);

                // get width of the original image
                $originalWidth = (integer) $originalImage->width();

                // calculate a width for the watermark
                $width = round($originalWidth / 3);

                // get watermark
                $watermark = Image::make($getWatermak->url);

                // resize watermark
                $watermark->resize(
                    $width, null, function ($constraint) {
                        $constraint->aspectRatio();
                    }
                );
                $originalImage->insert($watermark, 'center');
                $originalImage->save($url, 100);

                $image->deleteThumbs();
                $image->createDefaultThumbs();

            }else{
                return "Some files could not be watermaked. Please select only image files.";
            }
        }
        return "OK";
    }
637262
protected function addWatermarkFilterIfExists(&$set, $width, $height)
    {
        if( isset($set['watermark']) )
        {
            if( ! empty($set['watermark'][1])) 
            {
                $set['filters'][] = ['target', [$set['watermark'][1]]];
            }

            if( ! empty($set['watermark'][2])) 
            {
                $set['filters'][] = ['margin', [$set['watermark'][2]]];
            }

            $set['filters'][] = ['mix', [$set['watermark'][0]]];
        }  
    }
135068
function copyImage( $destinationImageObject, $imageObject,
                        $destinationX, $destinationY,
                        $sourceWidth, $sourceHeight, $sourceX = 0, $sourceY = 0 )
    {
        ImageCopy( $destinationImageObject, $imageObject,
                   $destinationX, $destinationY,
                   $sourceX, $sourceY, $sourceWidth, $sourceHeight );
    }
995437
def watermark_process():
    """"""
    # Redirect to watermark page that contains form
    if not request.method == 'POST':
        abort(403)

    # Check if the post request has the file part
    if 'pdf' not in request.files:
        abort(403)

    # Retrieve PDF file and parameters
    file = request.files['pdf']

    # If user does not select file, browser also submit an empty part without filename
    if file.filename == '':
        abort(403)

    # Check if the file is an allowed file type
    if not allowed_file(file.filename):
        abort(403)

    params = {
        'address': request.form['address'],
        'town': request.form['town'],
        'state': request.form['state'],
    }

    # Save file to uploads folder
    filename = secure_filename(file.filename)
    file_path = os.path.join(app.config['UPLOAD_FOLDER'], filename)

    # Make uploads directory if it does not exist
    if not os.path.exists(app.config['UPLOAD_FOLDER']):
        os.mkdir(app.config['UPLOAD_FOLDER'])

    file.save(file_path)

    # Create new watermarked file and return file path
    watermarked = apply_watermark(file_path, params)
    return send_from_directory(app.config['UPLOAD_FOLDER'], os.path.basename(watermarked))
691806
public function watermark(string $watermark_image, string $position)
    {
        $this->actions_to_perform[] = ['watermark', ['watermark_image' => $watermark_image, 'position' => $position]];

        return $this;
    }
534780
public function copyAndMergeFromWithGray(Image $srcImage, $x = 0, $y = 0, $opacity = 50, $srcX = 0, $srcY = 0, $srcWidth = 0, $srcHeight = 0) {
		if (empty($srcWidth)) {
			$srcWidth = $srcImage->getWidth();
		}
		if (empty($srcHeight)) {
			$srcHeight = $srcImage->getHeight();
		}
		return imagecopymergegray($this->image, $srcImage->image, $x, $y, $srcX, $srcY, $srcWidth, $srcHeight, $opacity);
	}