Last active
January 22, 2022 04:46
-
-
Save symisc/ee6f90e3a315317dcf79857c5aed7b06 to your computer and use it in GitHub Desktop.
Convert a given image to the grayscale color space using the PixLab API - https://pixlab.io/cmd?id=grayscale
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
import json | |
# Convert a given image to the grayscale color space. A grayscale (or graylevel) image is simply one in which the only colors are shades of gray. | |
# https://pixlab.io/cmd?id=grayscale for additional information. | |
req = requests.get( | |
'https://api.pixlab.io/grayscale', | |
params={ | |
'img':'https://www.allaboutbirds.org/guide/PHOTO/LARGE/blue_jay_8.jpg', | |
'key':'PIXLAB_API_KEY' # Your PixLab API Key - Get yours from the PixLab Console at https://console.pixlab.io/ | |
}) | |
reply = req.json() | |
if reply['status'] != 200: | |
print(reply['error']) | |
else: | |
print(f"Link to the grayscaled picture: {reply['ssl_link']}") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment