Answer the question
In order to leave comments, you need to log in
How to get non-broken link of processed image?
There is a python code like this
headers = {'Connection':'keep-alive',
'Accept':'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9',
'Accept-Encoding':'gzip,deflate',
'Accept-Language':'ru-RU,ru;q=0.9,en-US;q=0.8,en;q=0.7',
'Connection':'keep-alive',
'Access-Control-Allow-Origin': '*',
'Host':'color.photofuneditor.com',
'Upgrade-Insecure-Requests': '0',
'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.95 Safari/537.36'}
link_img[user_id] = src
with open(link_img[user_id], "rb") as image_file:
image_hash = base64.b64encode(image_file.read()).decode("utf-8")
encoded_image = 'data:image/jpeg;base64,{}'.format(image_hash)
payload = {'fileToUpload': encoded_image}
r = requests.post('http://color.photofuneditor.com/ceremony', data=payload, headers=headers)
if r.status_code == 200:
jv = "string: {}".format(r.json()['file_link'])
print(jv)
image_url = 'http://color.photofuneditor.com/output/{}'.format(r.json()['file_link'])
r = requests.get(image_url, headers=headers)
with open(str(user_id) + '.jpg', 'wb') as f:
f.write(r.content)
bot.send_message(message.chat.id, "Вот ваше фото с обработкой:")
photo = open(str(user_id) + '.jpg', "rb")
bot.send_photo(message.chat.id, photo)
os.remove(str(user_id) + '.jpg')
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question