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.1.tar.gz (5.2 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.1-py3-none-any.whl (6.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: watermarkpy-image-0.9.1.tar.gz
  • Upload date:
  • Size: 5.2 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.1.tar.gz
Algorithm Hash digest
SHA256 8bb526a9939f73798eae6e1993deda23b535e330726d2134765f10ad49c56f55
MD5 c19bb76507f06f6eb07ee79bb1849e21
BLAKE2b-256 be42dca97b07097f64e4dc4f8a200de57f9e9ae7d9e685419cef83215767a1ac

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for watermarkpy_image-0.9.1-py3-none-any.whl
Algorithm Hash digest
SHA256 5ff9544894c8137296fe5000879759cd3ba14af9455247046afa0527087108ed
MD5 cf157440ee1e9c950673ea4f803e938f
BLAKE2b-256 bdaa7dd2520a9626cb13566187f3523a74465f7dcd560d1572267c581b4548f7

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