This how-to is tell you how to add a watermark on the image file.

The image file is youtube.jpg, 1024×768.

I would like to add a watermark to the youtube.jpg. The watermark is a small picture.

Youtube.jpg

 

Watermark image

 

Install Imagemagick

sudo apt install imagemagick
 
davidyin@tesing_machine:~$ composite
Version: ImageMagick 6.9.7-4 Q16 x86_64 20170114 http://www.imagemagick.org
Copyright: © 1999-2017 ImageMagick Studio LLC
License: http://www.imagemagick.org/script/license.php
Features: Cipher DPC Modules OpenMP
Delegates (built-in): bzlib djvu fftw fontconfig freetype jbig jng jpeg lcms lqr ltdl lzma openexr pangocairo png tiff wmf x xml zlib
Usage: composite-im6.q16 [options ...] image [options ...] composite
  [ [options ...] mask ] [options ...] composite

Image Settings:
  -affine matrix       affine transform matrix
  -alpha option        on, activate, off, deactivate, set, opaque, copy
                       transparent, extract, background, or shape
  -authenticate password
                       decipher image with this password
  -blue-primary point  chromaticity blue primary point
  -channel type        apply option to select image channels
  -colorspace type     alternate image colorspace
  -comment string      annotate image with comment
  -compose operator    composite operator
  -compress type       type of pixel compression when writing the image
  -define format:option
                       define one or more image format options
  -depth value         image depth
  -density geometry    horizontal and vertical density of the image
  -display server      get image or font from this X server
  -dispose method      layer disposal method
  -dither method       apply error diffusion to image
  -encoding type       text encoding type
  -endian type         endianness (MSB or LSB) of the image
  -filter type         use this filter when resizing an image
  -font name           render text with this font
  -format "string"     output formatted image characteristics
  -gravity type        which direction to gravitate towards
  -green-primary point chromaticity green primary point
  -interlace type      type of image interlacing scheme
  -interpolate method  pixel color interpolation method
  -label string        assign a label to an image
  -limit type value    pixel cache resource limit
  -matte               store matte channel if the image has one
  -monitor             monitor progress
  -page geometry       size and location of an image canvas (setting)
  -pointsize value     font point size
  -quality value       JPEG/MIFF/PNG compression level
  -quiet               suppress all warning messages
  -red-primary point   chromaticity red primary point
  -regard-warnings     pay attention to warning messages
  -respect-parentheses settings remain in effect until parenthesis boundary
  -sampling-factor geometry
                       horizontal and vertical sampling factor
  -scene value         image scene number
  -seed value          seed a new sequence of pseudo-random numbers
  -size geometry       width and height of image
  -support factor      resize support: > 1.0 is blurry, < 1.0 is sharp
  -synchronize         synchronize image to storage device
  -taint               declare the image as modified
  -transparent-color color
                       transparent color
  -treedepth value     color tree depth
  -tile                repeat composite operation across and down image
  -units type          the units of image resolution
  -verbose             print detailed information about the image
  -virtual-pixel method
                       virtual pixel access method
  -white-point point   chromaticity white point

Image Operators:
  -blend geometry      blend images
  -border geometry     surround image with a border of color
  -bordercolor color   border color
  -colors value        preferred number of colors in the image
  -decipher filename    convert cipher pixels to plain pixels
  -displace geometry   shift lookup according to a relative displacement map
  -dissolve value      dissolve the two images a given percent
  -distort geometry    shift lookup according to a absolute distortion map
  -encipher filename   convert plain pixels to cipher pixels
  -extract geometry    extract area from image
  -geometry geometry   location of the composite image
  -identify            identify the format and characteristics of the image
  -monochrome          transform image to black and white
  -negate              replace every pixel with its complementary color
  -profile filename    add ICM or IPTC information profile to image
  -quantize colorspace reduce colors in this colorspace
  -repage geometry     size and location of an image canvas (operator)
  -rotate degrees      apply Paeth rotation to the image
  -resize geometry     resize the image
  -sharpen geometry    sharpen the image
  -shave geometry      shave pixels from the image edges
  -stegano offset      hide watermark within an image
  -stereo geometry     combine two image to create a stereo anaglyph
  -strip               strip image of all profiles and comments
  -thumbnail geometry  create a thumbnail of the image
  -transform           affine transform image
  -type type           image type
  -unsharp geometry    sharpen the image
  -watermark geometry  percent brightness and saturation of a watermark
  -write filename      write images to this file

Image Stack Operators:
  -swap indexes        swap two images in the image sequence

Miscellaneous Options:
  -debug events        display copious debugging information
  -help                print program options
  -list type           print a list of supported option arguments
  -log format          format of debugging information
  -version             print version information

By default, the image format of `file' is determined by its magic
number.  To specify a particular image format, precede the filename
with an image format name and a colon (i.e. ps:image) or specify the
image type as the filename suffix (i.e. image.ps).  Specify 'file' as
'-' for standard input or output.

Add Watermark

Run the following command to add the watermark. Composite command is the part of Imagemagick lib.

composite -gravity southeast -geometry +10+10 -dissolve 75% "watermark.jpg" "youtube.jpg" "youtube-with-watermark.jpg"
A picture with watermark

The watermark picture is located on the low right corner with 10px margin.  A little bit transparent on the watermark.

The watermark file is a jpg file in this example. I can also use a png file, which can be a transparent file.

Add a Transparent png watermark on the image

transparent png watermark

 

Now I put the watermark on the left low corner.

Transparent watermark on jpg file

David Yin

David is a blogger, geek, and web developer — founder of FreeInOutBoard.com. If you like his post, you can say thank you here

Leave a Reply

Your email address will not be published. Required fields are marked *