Look like a question for the pil mailing list. Anyway, stackoverflow suggest that you create a new image then paste the old image onto the new one. Here is the code from stackoverflow
newImage = Image.new(mode, (newWidth,newHeight)) newImage.paste(srcImage, (x1,y1, x1+oldWidth,y1+oldHeight)) I fear there is no way to make the image fit your content, you'll have to create an image big enough. I hope that won't be an issue for you 2017-04-08 16:27 GMT+02:00 Aamu Padi <aamup...@gmail.com>: > I am creating QRcode for each ticket. The QRcode is in image format. > > I want to extend this image vertically on both the sides (i.e. Top and > Bottom). And in the extended area I want to add some additional data like > this: > > Theater Name > _____________________ > | | > | | > | QR CODE | > | | > | | > | | > | | > | | > |____________________| > Seat id: 24 C > Movie: The baby boss > Showtime: 2:30 pm > Date: 09/04/17 > > > > Now I am doing this way to add image: > > image = Image.open('qrcode.jpg') > width, height = image.size > draw = ImageDraw.Draw(image) > text_cinema = "RPG Cinema" > text_seat = "Seat: 15C Balcony" > text_movie = "The baby boss" > text_showtime = "02:30 pm" > text_date = "09/04/17" > font = ImageFont.truetype('font.ttf', 24) > draw.text((40, 5), text_cinema, font=font) > draw.text((40,height - 40), text_seat, font=font) > draw.text((40,height + 40), text_movie, font=font) > draw.text((40,height + 40), text_showtime, font=font) > image.save(str(time()).replace('.', '_') + '.jpg') > > > And the image turns out to be in this way: > > > > > As you can see, the text are added into the image and not extending the > image itself. Also, other data like text_movie, text_showtime and > text_date are not being inserted as the text does not extend the image. > > How can I extend the image and insert texts into the extended image area? > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to django-users+unsubscr...@googlegroups.com. > To post to this group, send email to django-users@googlegroups.com. > Visit this group at https://groups.google.com/group/django-users. > To view this discussion on the web visit https://groups.google.com/d/ > msgid/django-users/CAHSNPWun8vu1eAprO_46iRPsq-qJuejjsLkWPXc%2BgxjKFsp5cQ% > 40mail.gmail.com > <https://groups.google.com/d/msgid/django-users/CAHSNPWun8vu1eAprO_46iRPsq-qJuejjsLkWPXc%2BgxjKFsp5cQ%40mail.gmail.com?utm_medium=email&utm_source=footer> > . > For more options, visit https://groups.google.com/d/optout. > -- Cordialement, Ludovic Coues +33 6 14 87 43 42 -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at https://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAEuG%2BTbYeJSznqF49oH3YP7WiLNg3E_QtPvouxc%3D4yUdUCbr7Q%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.