Monday, September 7, 2015

Water marking in django


Requirements for Water Marking : -

Download the packages ( apps ) from the github : https://github.com/renjithsraj/watermark_django

Install PIL , ImageKit in your Environments Using Pip Command,


create a project and apps , and

import the water_mark django in your apps views.py

from watermark_django.watermark import TextWatermark, ImageWatermark


        def set_image_watermark(request, watermark, img ):

         image_size = img.size
         scaled = ImageWatermark(watermark,
         position=('center', 'center'),
         scale=True,
        opacity=0.80)
        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),
text_color="red",
position=('center', 'center'),
opacity=0.75,
)
        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 = Image.open(water_img, 'r')

image_data = io.BytesIO(urllib2.urlopen(v).read())
real_image = Image.open(image_data,'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