B
B
Bla Bla2021-09-05 00:10:18
Python
Bla Bla, 2021-09-05 00:10:18

How to get the image url?

So guys, look, there is a request for the Google API service, and one of the parameters of the silk is for the picture, the picture is locally on my computer, so you need to somehow upload the picture (programmatically) to some kind of hosting (you can take a few seconds to send a request ) to get a snare on the picture. Preferably a Python example. Who can write a service on which to throw a photo. Thanks in advance to everyone for help!
My request:

import requests

url = "https://vision.googleapis.com/v1/images:annotate"

params = {"key":  "Your key"}
imageUrl = "URL of some photo" # example https://i.vimeocdn.com/video/766293448_1920x1080?r=pad
payload = {"imageUri": imageUrl}

res = requests.post(url, params = params, json = payload)
print(res.json())


PS I found something about amazon s3 bucket, it might help.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
sswwssww, 2021-09-05
@SubUser

https://api.imgbb.com/

import base64
import requests

with open("fig1.png", "rb") as file:
    url = "https://api.imgbb.com/1/upload"
    #  key_imgbb - это твой api ключ, получаешь его зарегавшись на сервисе
    payload = {
        "key": key_imgbb,
        "image": base64.b64encode(file.read()),
    }
    res = requests.post(url, payload)
print(res.json())  # забираешь отсюда нужную тебе ссылку на файл, и отправляешь в google

The code is not mine, it's better to write everything asynchronously, but it will work anyway.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question