Skip to main content

Add watermark-image in one or multiple images at once.

Project description

example workflow codecov

WaterMarkPy


WaterMarkPy is a simple free open-source library to add watermark in images. The WaterMarkPy keeps the watermark with the same locate and with the same size in the image despite of the image resolution, because the WaterMarkPy uses percent (%) unit to position the watermark.

You can find the source code at: https://github.com/VictorCarlquist/WaterMarkPy/,

Install

pip install watermarkpy-image

To add a watermark in the center of one image, run:

from watermarkpy.watermark import WMImage

main_image = "img/ship.jpg"
watermark = "img/shipwm.jpg"

with Image.open(main_image) as main, Image.open(watermark) as wm:
    wm = WMImage(main, wm)
    img = wm.createWMCenter()
    img.save("new.jpg", "JPEG")

To add a watermark in the center of one image with a different scale and alpha, run:

from watermarkpy.watermark import WMImage

main_image = "img/ship.jpg"
watermark = "img/shipwm.jpg"

with Image.open(main_image) as main, Image.open(watermark) as wm:
    wm = WMImage(main, wm)
    img = wm.createWMCenter(scale=25, alpha=120)
    img.save("new.jpg", "JPEG")

Parameters:

scale = [0% - 100%]
alpha = [0 - 255]

To add a watermark in a diffente position, run:

from watermarkpy.watermark import WMImage

main_image = "img/ship.jpg"
watermark = "img/shipwm.jpg"

with Image.open(main_image) as main, Image.open(watermark) as wm:
    wm = WMImage(main, wm)
    img = wm.createWMCustom(marginTop=70 marginLeft=60, scale=25, alpha=120)
    img.save("new.jpg", "JPEG")

Parameters:

marginTop = [0% - 100%]
marginLeft = [0% - 100%]
scale = [0% - 100%]
alpha = [0 - 255]

To add a watermark and improve the brightness based in the brightness of the background region, run:

from watermarkpy.watermark import WMImage

main_image = "img/ship.jpg"
watermark = "img/shipwm.jpg"

with Image.open(main_image) as main, Image.open(watermark) as wm:
    wm = WMImage(main, wm)
    img = wm.createWMCustom(marginTop=70 marginLeft=60, adjust_color=True)
    img.save("new.jpg", "JPEG")

Parameters:

marginTop = [0% - 100%]
marginLeft = [0% - 100%]
adjust_color = [True, False]

To add a watermark in the center of one image, run:

watermarkpy-image -i name.bmp -w nameWM.png -o name_output

* -i: path to image
* -w: path to watermark image
* -o: name of the output image

To add a watermark in the center of multiples images in a folder, run:

watermarkpy-image -d imgs/ -w nameWM.png

* -d: path to folder
* -w: path to watermark image

To scale (resize) the watermark image and define a relative position in one image, run:

watermarkpy-image -i imgs/name.bmp -w nomeWM.png -s 10 -mt 25 -ml 25 -o name_output

* -i: path to image
* -w: path to watermark image
* -s: % scale size to watermark image
* -mt: position in % from TOP margin
* -ml: position in % from LEFT margin
* -o: name of the output image

To scale (resize) the watermark image and define a relative position in multiples image in a folder, run:

watermarkpy-image -d imgs/ -w nomeWM.png -s 30 -mt 25 -ml 25

* -d: path to folder
* -w: path to watermark image
* -s: % scale size to watermark image
* -mt: position in % from TOP margin
* -ml: position in % from LEFT margin

Parameters:

> -i path to image
>> ex: -i img/img.bmp

> -w path to watermark image
>> ex: -i img/wm.bmp

> -d path to folder with image
>> ex: -d img/

> -s scale/resize (in %) watermark considering the dimensions of the main image
>> ex: -s 30

> -mt Margin TOP in %.
>> ex: -mt 20

> -ml Margin LEFT in %.
>> ex: -ml 20

> -negative invert colors of the watermark considering bg color of the main image
>> ex: -negative

> -p Add a prefix in the name of output image in a batch operation.
>> ex: -p water

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

watermarkpy-image-0.9.3.tar.gz (6.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

watermarkpy_image-0.9.3-py3-none-any.whl (6.9 kB view details)

Uploaded Python 3

File details

Details for the file watermarkpy-image-0.9.3.tar.gz.

File metadata

  • Download URL: watermarkpy-image-0.9.3.tar.gz
  • Upload date:
  • Size: 6.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.10.4

File hashes

Hashes for watermarkpy-image-0.9.3.tar.gz
Algorithm Hash digest
SHA256 1d3867567326297c3c3e523d2dbe87e18267dfde2b25722f20b604e2225ddc99
MD5 6cdc1c1134f4cb958d3e76e2021836f7
BLAKE2b-256 09847b85da2f40fa96e0632e4836477f4e25663d5bd6690980e60a2ccb3c53e6

See more details on using hashes here.

File details

Details for the file watermarkpy_image-0.9.3-py3-none-any.whl.

File metadata

File hashes

Hashes for watermarkpy_image-0.9.3-py3-none-any.whl
Algorithm Hash digest
SHA256 ad7798e28906ed51d67167dcaf22caa78e7e342f01b3b0a498c23165dab0c600
MD5 9044e26fb88353e00fef18be39ef778e
BLAKE2b-256 0ecfa2031000913c0968534439ad62137d9de1309373e8c7f3aefff73514b083

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page