Posts

Showing posts with the label python-imaging-library

Add Text on Image using PIL

Image
Clash Royale CLAN TAG #URR8PPP Add Text on Image using PIL I have an application that loads an Image and when the user clicks it, a text area appears for this Image (using jquery ), where user can write some text on the Image. Which should be added on Image. jquery After doing some research on it, I figured that PIL (Python Imaging Library ) can help me do this. So I tried couple of examples to see how it works and I managed to write text on an image. But I think there is some difference when I try it using Python Shell and in web environment. I mean the text on the textarea is very big in px. How can I achieve the same size of text when using PIL as the one on the textarea? PIL Python Shell The text is Multiline. How can i make it multiline in image also, using PIL ? PIL Is there a better way than using PIL? I am not entirely sure, If this is the best implementation. html: <img src="images/test.jpg"/> its the image being edited var count = 0; $('textarea').a...

Overwriting a border on an image in Python PIL

Image
Clash Royale CLAN TAG #URR8PPP Overwriting a border on an image in Python PIL I have a gallery application where the users upload photos and my code gives it a border, writes some of the photo attributes on the border and stores it. image2 = Image.open('media/' + str(image.file)) width, height = image2.size; image2 = ImageOps.expand(image2, border=(int(width/25),int(height/20),int(width/25),int(height/10)), fill='rgb(0,0,0)') (Note that here my bottom border is longer than the top because I am writing attributes on the bottom border.) Now I'm building an edit feature for the uploaded images where the user can change the attributes of the uploaded images. But the attributes that are already written on the border have to be overwritten. So here, my approach is to put a black patch on the bottom border and re-write the new attributes without changes the top and side borders and without changing the aspect ratio. All of this has to be done using PIL. Question is how do ...