Monday, September 7, 2015

Water marking in django

Requirements for Water Marking : -

Download the packages ( apps ) from the github :

Install PIL , ImageKit in your Environments Using Pip Command,

create a project and apps , and

import the water_mark django in your apps

from watermark_django.watermark import TextWatermark, ImageWatermark

        def set_image_watermark(request, watermark, img ):

         image_size = img.size
         scaled = ImageWatermark(watermark,
         position=('center', 'center'),
        img_scaled = scaled.process(img, image_size[0])
        return img_scaled

      def set_text_watermark(request, water_text, im ):

        title_mark = TextWatermark(water_text,
font=(settings.TEXT_WATER_MARK_FONT, 50),
position=('center', 'center'),
        img = title_mark.process(im)
        return img

         def create_watermark(request):
water_url = example.png
                text_watermark = "I Love You My Dear "
water_img = io.BytesIO(urllib2.urlopen(water_url).read())
mark =, 'r')

image_data = io.BytesIO(urllib2.urlopen(v).read())
real_image =,'r')
image_watermark_output = set_image_watermark(request, mark, real_image)
                text_water_maark = set_text_watermark(request,text_watermark, real_image)

this watermark_django packages is need python image library ( pil or pillow) , Image Kit


No comments:

Post a Comment