Play With Pillow

Who hasn't heard PIL? It's an image processing library made by python (Python Image Library). Pillow is an extension of it. So installing pillow is really easy: pip install pillow Now we are going to do some image processing cool stuff: First Load Image: from PIL import Image, ImageOps img ='image.png') Resize Image Suppose We want to resize an image and maintain its aspect ratio. Here we need to get the aspect ratio after resizing. Here is a snippet for it: def get_resize_image_size(image,…

Keep reading

Categories: image-processing, Python, pil, pillow, Django, technical-blogs

Python: Selenium with PhantomJs to capture Screenshots

PhantomJS is a headless WebKit scriptable with a JavaScript API. It has fast and native support for various web standards: DOM handling, CSS selector, JSON, Canvas, and SVG. And Selenium is a portable software-testing framework for web applications. Selenium provides a record/playback tool for authoring tests without the need to learn a test scripting language (Selenium IDE) Using the combination of selenium and PhantomJs can give you a way to capture screenshots and use it in your choices. For that let's install PhantomJs in your computer. For Ubuntu/Debian…

Keep reading

Categories: Django, Selenium, PhantomJs, Python, technical-blogs

Documentation Of Django Encrypt File

Django Encrypt File is a simple Library which can be used to encrypt uploaded files and store them. Installation Use pip to install it: pip install djangoencryptfile Or pip install Basic Usage from djangoencryptfile import EncryptionService from django.core.files import File password = '1234' service = EncryptionService(raise_exception=False) open('', 'rb') as inputfile: usefile = File(inputfile, name='') encrypted_file = service.encrypt_file(useFile, password, extension='enc') # it will save decrypt_file = service.decrypt_file(encrypted_…

Keep reading

Categories: Django, Django-Encrypt-File, documentation, technical-blogs

Docker: Use Celery in Django(Redis as Broker)

In previous two posts, we have deployed Django with Postgres, Nginx, now its time to do some async stuff using Celery. In this post, I will do the magic tricks first, explain them later. Add Celery to Django To add celery, we need make a container for celery. We can re-use the Dockerfile of django for making celery's container like this: FROM python:latest ENV PYTHONUNBUFFERED 1 #ENV C_FORCE_ROOT true # intentionally kept it commented ENV APP_USER user ENV APP_ROOT /src RUN groupadd -r ${APP_USER} \ &…

Keep reading

Categories: Django, Docker, Celery, technical-blogs

Serve Static Files by Nginx from Django using Docker

This is more of a follow up post of my previous blog. Before I start, I am assuming you have successfully deployed django using docker & nginx, but having some problems serving static files. No worries, its easy. Just follow these steps: 1. In your django file, add static file directory i.e. STATIC_ROOT=/static. So what it will do is, when you run collectstatic command(python collectstatic), it will store the static files in your /static directory of OS. 2. Now in docker-compose.yml…

Keep reading

Categories: Django, Docker, Nginx, technical-blogs