python cv2 load image from image file, url or base64 code of image
Project description
cv2ImageLoad
python cv2通过图片文件、图片url、图片的base64编码加载图片。cv2ImageLoad
安装
pip install cv2imageload
使用
from cv2imageload import ImageLoad, ImageLoadError
file = 'th-108.jpg'
url = 'http://*.com/test.png'
base64_str = '图片的base64编码字符串'
# 加载图片文件
try:
image = ImageLoad.loadImage(file)
except ImageLoadError as e:
print(e.reason)
# 加载url图片
try:
image = ImageLoad.loadImage(url)
except ImageLoadError as e:
print(e.reason)
# 加载base64编码的图片
try:
image = ImageLoad.loadImage(base64_str)
except ImageLoadError as e:
print(e.reason)
# 将图片编码为base64字符串
try:
base64_str = ImageLoad.base64EncodeImage(image, with_base64_header=True, file_ext='jpg')
except ImageLoadError as error:
print(error.reason)
print(base64_str[:30])
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
cv2imageload-1.0.5.tar.gz
(3.5 kB
view hashes)
Built Distribution
Close
Hashes for cv2imageload-1.0.5-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f44d81eeed8066be90e033dac2e40932d52b1e0f1dda3c3a845b5396fb533466 |
|
MD5 | ee246d9520b3b9e162ed3a84b097329a |
|
BLAKE2b-256 | a663418d310a6c358335ab923f1ff5c4bc2d77b0ed8cdfbc34f37ff918d99dde |