note 127542 added to book.image
| From: | celsomoises629 at gmail dot com | Date: | Fri, 26 Aug 2022 20:47:02 +0000 |
| Subject: | note 127542 added to book.image | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-219480@lists.php.net to get a copy of this message | ||
#author: PySemos
#email: celsomoises629@gmail.com
import requests # Requests is a library for doing online requests
from PIL import Image # PIL (Pillow), is a library for handling images
from PIL import ImageDraw
from PIL import ImageFont
import os
def download_photo(url:str,photo_name:str)->None:
"""
This function will download an image and 'll create a file with name as photo_name
"""
resp = requests.get(url)
image = resp.content
with open(photo_name,"wb") as file:
file.write(image)
return
if __name__ == "__main__":
image_url ="https://hatrabbits.com/wp-content/uploads/2017/01/random.jpg"
download_photo(image_url,image_name)
with Image.open(image_name) as img:
draw = ImageDraw.Draw(img)
font = ImageFont.truetype("arial.ttf",50)
draw.text((40,250),"From Verkkostadi",font = font)
file_name = os.path.splitext(os.path.split(image_name)[1])[0] #This line only take the
name of the file without extension
new_file_name = file_name + "_modified" +
os.path.splitext(os.path.split(image_name)[1])[1] # This file only add the "_modified"
to the name of the file
img.save(new_file_name) # Saving the file
----
Server IP: 45.112.84.4
Probable Submitter: 185.85.3.173 (proxied: 2601:8b:8403:6890:d10:27fb:87e4:b1f2)
----
Manual Page -- https://php.net/manual/en/book.image.php
Edit -- https://main.php.net/note/edit/127542
Del: integrated -- https://main.php.net/note/delete/127542/integrated
Del: useless -- https://main.php.net/note/delete/127542/useless
Del: bad code -- https://main.php.net/note/delete/127542/bad+code
Del: spam -- https://main.php.net/note/delete/127542/spam
Del: non-english -- https://main.php.net/note/delete/127542/non-english
Del: in docs -- https://main.php.net/note/delete/127542/in+docs
Del: other reasons-- https://main.php.net/note/delete/127542
Reject -- https://main.php.net/note/reject/127542
Search -- https://main.php.net/manage/user-notes.php