# Less trouble reading/writing images with OpenCV
```python
$pip install a-cv-imwrite-imread-plus
from a_cv_imwrite_imread_plus import add_imwrite_plus_imread_plus_to_cv2
add_imwrite_plus_imread_plus_to_cv2()
cv2.imwrite_plus("f:\\ö\\ö\\ö\\öädssdzß.jpg", base64img2cv)
#or:
from a_cv_imwrite_imread_plus import save_cv_image
save_cv_image("f:\\ö\\ö\\ö\\öädssdzß.jpg", base64img2cv)
Parameters:
filepath:str
folders will be created if they don't exist
image:np.ndarray
image as np
Returns:
filepath:str
```
```python
from a_cv_imwrite_imread_plus import add_imwrite_plus_imread_plus_to_cv2
add_imwrite_plus_imread_plus_to_cv2()
import base64
from PIL import Image
import cv2
#Base64
base64img = r"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAAApgAAAKYB3X3/OAAAABl0RVh0U29mdHdhcmUAd3d3Lmlua3NjYXBlLm9yZ5vuPBoAAANCSURBVEiJtZZPbBtFFMZ/M7ubXdtdb1xSFyeilBapySVU8h8OoFaooFSqiihIVIpQBKci6KEg9Q6H9kovIHoCIVQJJCKE1ENFjnAgcaSGC6rEnxBwA04Tx43t2FnvDAfjkNibxgHxnWb2e/u992bee7tCa00YFsffekFY+nUzFtjW0LrvjRXrCDIAaPLlW0nHL0SsZtVoaF98mLrx3pdhOqLtYPHChahZcYYO7KvPFxvRl5XPp1sN3adWiD1ZAqD6XYK1b/dvE5IWryTt2udLFedwc1+9kLp+vbbpoDh+6TklxBeAi9TL0taeWpdmZzQDry0AcO+jQ12RyohqqoYoo8RDwJrU+qXkjWtfi8Xxt58BdQuwQs9qC/afLwCw8tnQbqYAPsgxE1S6F3EAIXux2oQFKm0ihMsOF71dHYx+f3NND68ghCu1YIoePPQN1pGRABkJ6Bus96CutRZMydTl+TvuiRW1m3n0eDl0vRPcEysqdXn+jsQPsrHMquGeXEaY4Yk4wxWcY5V/9scqOMOVUFthatyTy8QyqwZ+k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8RDwJrU+qXkjWtfi8Xxt58BdQuwQs9qC/afLwCw8tnQbqYAPsgxE1S6F3EAIXux2oQFKm0ihMsOF71dHYx+f3NND68ghCu1YIoePPQN1pGRABkJ6Bus96CutRZMydTl+TvuiRW1m3n0eDl0vRPcEysqdXn+jsQPsrHMquGeXEaY4Yk4wxWcY5V/9scqOMOVUFthatyTy8QyqwZ+kDURKoMWxNKr2EeqVKcTNOajqKoBgOE28U4tdQl5p5bwCw7BWquaZSzAPlwjlithJtp3pTImSqQRrb2Z8PHGigD4RZuNX6JYj6wj7O4TFLbCO/Mn/m8R+h6rYSUb3ekokRY6f/YukArN979jcW+V/S8g0eT/N3VN3kTqWbQ428m9/8k0P/1aIhF36PccEl6EhOcAUCrXKZXXWS3XKd2vc/TRBG9O5ELC17MmWubD2nKhUKZa26Ba2+D3P+4/MNCFwg59oWVeYhkzgN/JDR8deKBoD7Y+ljEjGZ0sosXVTvbc6RHirr2reNy1OXd6pJsQ+gqjk8VWFYmHrwBzW/n+uMPFiRwHB2I7ih8ciHFxIkd/3Omk5tCDV1t+2nNu5sxxpDFNx+huNhVT3/zMDz8usXC3ddaHBj1GHj/As08fwTS7Kt1HBTmyN29vdwAw+/wbwLVOJ3uAD1wi/dUH7Qei66PfyuRj4Ik9is+hglfbkbfR3cnZm7chlUWLdwmprtCohX4HUtlOcQjLYCu+fzGJH2QRKvP3UNz8bWk1qMxjGTOMThZ3kvgLI5AzFfo379UAAAAASUVORK5CYII="
base64imgcv = cv2.imread_plus(base64img)
base64img2cv = cv2.imread_plus(base64img2)
base64imgcv = cv2.imread_plus(base64img, channels_in_output=4)
base64img2cv = cv2.imread_plus(base64img2, channels_in_output=4)
base64imgcv = cv2.imread_plus(base64img, channels_in_output=2)
base64img2cv = cv2.imread_plus(base64img2, channels_in_output=2)
#urls
pininterestlogo = "https://camo.githubusercontent.com/7f81f312b05694ccc8cd29e3c3466945ff8e73a13320d3fd0f90c6915bbb4ffb/68747470733a2f2f63646e2e6a7364656c6976722e6e65742f67682f646d68656e647269636b732f7369676e61747572652d736f6369616c2d69636f6e732f69636f6e732f726f756e642d666c61742d66696c6c65642f353070782f70696e7465726573742e706e67"
linkcv1 = cv2.imread_plus(pininterestlogo)
linkcv2 = cv2.imread_plus(pininterestlogo, channels_in_output=4)
linkcv3 = cv2.imread_plus(pininterestlogo, channels_in_output=2)
linkcv4 = cv2.imread_plus(pininterestlogo, channels_in_output=3)
#bytes/raw data
byteimage = base64.b64decode(base64img2)
byteimage1 = cv2.imread_plus(byteimage)
byteimage2 = cv2.imread_plus(byteimage, channels_in_output=4)
byteimage3 = cv2.imread_plus(byteimage, channels_in_output=2)
byteimage4 = cv2.imread_plus(byteimage, channels_in_output=3)
#PIL
pilimage = Image.fromarray(byteimage2)
pilimage1 = cv2.imread_plus(pilimage)
pilimage2 = cv2.imread_plus(pilimage, channels_in_output=4)
pilimage3 = cv2.imread_plus(pilimage, channels_in_output=2)
pilimage4 = cv2.imread_plus(pilimage, channels_in_output=3)
#float images to np.uint8
floatimage = pilimage4.astype(float)
floatimage1 = cv2.imread_plus(floatimage)
floatimage2 = cv2.imread_plus(floatimage, channels_in_output=4)
floatimage3 = cv2.imread_plus(floatimage, channels_in_output=2)
floatimage4 = cv2.imread_plus(floatimage, channels_in_output=3)
#filepath
filepath = "c:\\testestestes.png"
pilimage.save(filepath)
filepath1 = cv2.imread_plus(filepath, bgr_to_rgb=True)
filepath2 = cv2.imread_plus(filepath, channels_in_output=4, bgr_to_rgb=True)
filepath3 = cv2.imread_plus(filepath, channels_in_output=2, bgr_to_rgb=True)
filepath4 = cv2.imread_plus(filepath, channels_in_output=3, bgr_to_rgb=True)
#or:
from a_cv_imwrite_imread_plus import open_image_in_cv
#Base64
base64img = r"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAAApgAAAKYB3X3/OAAAABl0RVh0U29mdHdhcmUAd3d3Lmlua3NjYXBlLm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+gqjk8VWFYmHrwBzW/n+uMPFiRwHB2I7ih8ciHFxIkd/3Omk5tCDV1t+2nNu5sxxpDFNx+huNhVT3/zMDz8usXC3ddaHBj1GHj/As08fwTS7Kt1HBTmyN29vdwAw+/wbwLVOJ3uAD1wi/dUH7Qei66PfyuRj4Ik9is+hglfbkbfR3cnZm7chlUWLdwmprtCohX4HUtlOcQjLYCu+fzGJH2QRKvP3UNz8bWk1qMxjGTOMThZ3kvgLI5AzFfo379UAAAAASUVORK5CYII="
base64imgcv = open_image_in_cv(base64img)
base64img2cv = open_image_in_cv(base64img2)
base64imgcv = open_image_in_cv(base64img, channels_in_output=4)
base64img2cv = open_image_in_cv(base64img2, channels_in_output=4)
base64imgcv = open_image_in_cv(base64img, channels_in_output=2)
base64img2cv = open_image_in_cv(base64img2, channels_in_output=2)
#urls
pininterestlogo = "https://camo.githubusercontent.com/7f81f312b05694ccc8cd29e3c3466945ff8e73a13320d3fd0f90c6915bbb4ffb/68747470733a2f2f63646e2e6a7364656c6976722e6e65742f67682f646d68656e647269636b732f7369676e61747572652d736f6369616c2d69636f6e732f69636f6e732f726f756e642d666c61742d66696c6c65642f353070782f70696e7465726573742e706e67"
linkcv1 = open_image_in_cv(pininterestlogo)
linkcv2 = open_image_in_cv(pininterestlogo, channels_in_output=4)
linkcv3 = open_image_in_cv(pininterestlogo, channels_in_output=2)
linkcv4 = open_image_in_cv(pininterestlogo, channels_in_output=3)
#bytes/raw data
byteimage = base64.b64decode(base64img2)
byteimage1 = open_image_in_cv(byteimage)
byteimage2 = open_image_in_cv(byteimage, channels_in_output=4)
byteimage3 = open_image_in_cv(byteimage, channels_in_output=2)
byteimage4 = open_image_in_cv(byteimage, channels_in_output=3)
#PIL
pilimage = Image.fromarray(byteimage2)
pilimage1 = open_image_in_cv(pilimage)
pilimage2 = open_image_in_cv(pilimage, channels_in_output=4)
pilimage3 = open_image_in_cv(pilimage, channels_in_output=2)
pilimage4 = open_image_in_cv(pilimage, channels_in_output=3)
#float images to np.uint8
floatimage = pilimage4.astype(float)
floatimage1 = open_image_in_cv(floatimage)
floatimage2 = open_image_in_cv(floatimage, channels_in_output=4)
floatimage3 = open_image_in_cv(floatimage, channels_in_output=2)
floatimage4 = open_image_in_cv(floatimage, channels_in_output=3)
#filepath
filepath = "c:\\testestestes.png"
pilimage.save(filepath)
filepath1 = open_image_in_cv(filepath, bgr_to_rgb=True)
filepath2 = open_image_in_cv(filepath, channels_in_output=4, bgr_to_rgb=True)
filepath3 = open_image_in_cv(filepath, channels_in_output=2, bgr_to_rgb=True)
filepath4 = open_image_in_cv(filepath, channels_in_output=3, bgr_to_rgb=True)
from a_cv2_imshow_thread import add_imshow_thread_to_cv2
add_imshow_thread_to_cv2()
cv2.imshow_thread(
[
base64imgcv,
base64img2cv,
linkcv1,
linkcv2,
linkcv3,
linkcv4,
byteimage1,
byteimage2,
byteimage3,
byteimage4,
pilimage1,
pilimage2,
pilimage3,
pilimage4,
floatimage1,
floatimage2,
floatimage3,
floatimage4,
filepath1,
filepath2,
filepath3,
filepath4,
]
)
Parameters:
image:Any
Can be URL, bytes, base64, file path, np.ndarray, PIL
channels_in_output:Union[int,None]
None (original image won't be changed)
2 (GRAY)
3 (BGR)
4 (BGRA)
(default=None)
bgr_to_rgb:bool=False
Converts BGRA to RGBA / BGR to RGB
Returns:
image:np.ndarray
(Always as np.uint8)
```
Raw data
{
"_id": null,
"home_page": "https://github.com/hansalemaos/a_cv_imwrite_imread_plus",
"name": "a-cv-imwrite-imread-plus",
"maintainer": "",
"docs_url": null,
"requires_python": "",
"maintainer_email": "",
"keywords": "opencv,cv2,numpy,cv",
"author": "Johannes Fischer",
"author_email": "aulasparticularesdealemaosp@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/7b/92/a8aaac221e8a5d21da57e88ef6f7c6cda0d24ad1d89f2576987f17f6bf92/a_cv_imwrite_imread_plus-0.13.tar.gz",
"platform": null,
"description": "\r\n# Less trouble reading/writing images with OpenCV\r\n\r\n```python\r\n$pip install a-cv-imwrite-imread-plus\r\nfrom a_cv_imwrite_imread_plus import add_imwrite_plus_imread_plus_to_cv2\r\nadd_imwrite_plus_imread_plus_to_cv2()\r\ncv2.imwrite_plus(\"f:\\\\\u00f6\\\\\u00f6\\\\\u00f6\\\\\u00f6\u00e4dssdz\u00df.jpg\", base64img2cv)\r\n\r\n#or:\r\nfrom a_cv_imwrite_imread_plus import save_cv_image\r\nsave_cv_image(\"f:\\\\\u00f6\\\\\u00f6\\\\\u00f6\\\\\u00f6\u00e4dssdz\u00df.jpg\", base64img2cv)\r\n\r\n\r\n\tParameters:\r\n\t\tfilepath:str\r\n\t\t\tfolders will be created if they don't exist\r\n\t\timage:np.ndarray\r\n\t\t\timage as np\r\n\tReturns:\r\n\t\tfilepath:str\r\n```\r\n\r\n\r\n```python\r\nfrom a_cv_imwrite_imread_plus import add_imwrite_plus_imread_plus_to_cv2\r\nadd_imwrite_plus_imread_plus_to_cv2()\r\nimport base64\r\nfrom PIL import Image\r\nimport cv2\r\n\r\n#Base64\r\nbase64img = r\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAAApgAAAKYB3X3/OAAAABl0RVh0U29mdHdhcmUAd3d3Lmlua3NjYXBlLm9yZ5vuPBoAAANCSURBVEiJtZZPbBtFFMZ/M7ubXdtdb1xSFyeilBapySVU8h8OoFaooFSqiihIVIpQBKci6KEg9Q6H9kovIHoCIVQJJCKE1ENFjnAgcaSGC6rEnxBwA04Tx43t2FnvDAfjkNibxgHxnWb2e/u992bee7tCa00YFsffekFY+nUzFtjW0LrvjRXrCDIAaPLlW0nHL0SsZtVoaF98mLrx3pdhOqLtYPHChahZcYYO7KvPFxvRl5XPp1sN3adWiD1ZAqD6XYK1b/dvE5IWryTt2udLFedwc1+9kLp+vbbpoDh+6TklxBeAi9TL0taeWpdmZzQDry0AcO+jQ12RyohqqoYoo8RDwJrU+qXkjWtfi8Xxt58Bd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7tCa00YFsffekFY+nUzFtjW0LrvjRXrCDIAaPLlW0nHL0SsZtVoaF98mLrx3pdhOqLtYPHChahZcYYO7KvPFxvRl5XPp1sN3adWiD1ZAqD6XYK1b/dvE5IWryTt2udLFedwc1+9kLp+vbbpoDh+6TklxBeAi9TL0taeWpdmZzQDry0AcO+jQ12RyohqqoYoo8RDwJrU+qXkjWtfi8Xxt58BdQuwQs9qC/afLwCw8tnQbqYAPsgxE1S6F3EAIXux2oQFKm0ihMsOF71dHYx+f3NND68ghCu1YIoePPQN1pGRABkJ6Bus96CutRZMydTl+TvuiRW1m3n0eDl0vRPcEysqdXn+jsQPsrHMquGeXEaY4Yk4wxWcY5V/9scqOMOVUFthatyTy8QyqwZ+kDURKoMWxNKr2EeqVKcTNOajqKoBgOE28U4tdQl5p5bwCw7BWquaZSzAPlwjlithJtp3pTImSqQRrb2Z8PHGigD4RZuNX6JYj6wj7O4TFLbCO/Mn/m8R+h6rYSUb3ekokRY6f/YukArN979jcW+V/S8g0eT/N3VN3kTqWbQ428m9/8k0P/1aIhF36PccEl6EhOcAUCrXKZXXWS3XKd2vc/TRBG9O5ELC17MmWubD2nKhUKZa26Ba2+D3P+4/MNCFwg59oWVeYhkzgN/JDR8deKBoD7Y+ljEjGZ0sosXVTvbc6RHirr2reNy1OXd6pJsQ+gqjk8VWFYmHrwBzW/n+uMPFiRwHB2I7ih8ciHFxIkd/3Omk5tCDV1t+2nNu5sxxpDFNx+huNhVT3/zMDz8usXC3ddaHBj1GHj/As08fwTS7Kt1HBTmyN29vdwAw+/wbwLVOJ3uAD1wi/dUH7Qei66PfyuRj4Ik9is+hglfbkbfR3cnZm7chlUWLdwmprtCohX4HUtlOcQjLYCu+fzGJH2QRKvP3UNz8bWk1qMxjGTOMThZ3kvgLI5AzFfo379UAAAAASUVORK5CYII=\"\r\nbase64imgcv = cv2.imread_plus(base64img)\r\nbase64img2cv = cv2.imread_plus(base64img2)\r\nbase64imgcv = cv2.imread_plus(base64img, channels_in_output=4)\r\nbase64img2cv = cv2.imread_plus(base64img2, channels_in_output=4)\r\nbase64imgcv = cv2.imread_plus(base64img, channels_in_output=2)\r\nbase64img2cv = cv2.imread_plus(base64img2, channels_in_output=2)\r\n\r\n#urls\r\npininterestlogo = \"https://camo.githubusercontent.com/7f81f312b05694ccc8cd29e3c3466945ff8e73a13320d3fd0f90c6915bbb4ffb/68747470733a2f2f63646e2e6a7364656c6976722e6e65742f67682f646d68656e647269636b732f7369676e61747572652d736f6369616c2d69636f6e732f69636f6e732f726f756e642d666c61742d66696c6c65642f353070782f70696e7465726573742e706e67\"\r\nlinkcv1 = cv2.imread_plus(pininterestlogo)\r\nlinkcv2 = cv2.imread_plus(pininterestlogo, channels_in_output=4)\r\nlinkcv3 = cv2.imread_plus(pininterestlogo, channels_in_output=2)\r\nlinkcv4 = cv2.imread_plus(pininterestlogo, channels_in_output=3)\r\n\r\n#bytes/raw data\r\nbyteimage = base64.b64decode(base64img2)\r\nbyteimage1 = cv2.imread_plus(byteimage)\r\nbyteimage2 = cv2.imread_plus(byteimage, channels_in_output=4)\r\nbyteimage3 = cv2.imread_plus(byteimage, channels_in_output=2)\r\nbyteimage4 = cv2.imread_plus(byteimage, channels_in_output=3)\r\n\r\n#PIL\r\npilimage = Image.fromarray(byteimage2)\r\npilimage1 = cv2.imread_plus(pilimage)\r\npilimage2 = cv2.imread_plus(pilimage, channels_in_output=4)\r\npilimage3 = cv2.imread_plus(pilimage, channels_in_output=2)\r\npilimage4 = cv2.imread_plus(pilimage, channels_in_output=3)\r\n\r\n#float images to np.uint8\r\nfloatimage = pilimage4.astype(float)\r\nfloatimage1 = cv2.imread_plus(floatimage)\r\nfloatimage2 = cv2.imread_plus(floatimage, channels_in_output=4)\r\nfloatimage3 = cv2.imread_plus(floatimage, channels_in_output=2)\r\nfloatimage4 = cv2.imread_plus(floatimage, channels_in_output=3)\r\n\r\n#filepath\r\nfilepath = \"c:\\\\testestestes.png\"\r\npilimage.save(filepath)\r\nfilepath1 = cv2.imread_plus(filepath, bgr_to_rgb=True)\r\nfilepath2 = cv2.imread_plus(filepath, channels_in_output=4, bgr_to_rgb=True)\r\nfilepath3 = cv2.imread_plus(filepath, channels_in_output=2, bgr_to_rgb=True)\r\nfilepath4 = cv2.imread_plus(filepath, channels_in_output=3, bgr_to_rgb=True)\r\n\r\n\r\n\r\n#or:\r\nfrom a_cv_imwrite_imread_plus import open_image_in_cv\r\n#Base64\r\nbase64img = r\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAAApgAAAKYB3X3/OAAAABl0RVh0U29mdHdhcmUAd3d3Lmlua3NjYXBlLm9yZ5vuPBoAAANCSURBVEiJtZZPbBtFFMZ/M7ubXdtdb1xSFyeilBapySVU8h8OoFaooFSqiihIVIpQBKci6KEg9Q6H9kovIHoCIVQJJCKE1ENFjnAgcaSGC6rEnxBwA04Tx43t2FnvDAfjkNibxgHxnWb2e/u992bee7tCa00YFsffekFY+nUzFtjW0LrvjRXrCDIAaPLlW0nHL0SsZtVoaF98mLrx3pdhOqLtYPHChahZcYYO7KvPFxvRl5XPp1sN3adWiD1ZAqD6XYK1b/dvE5IWryTt2udLFedwc1+9kLp+vbbpoDh+6TklxBeAi9TL0taeWpdmZzQDry0AcO+jQ12RyohqqoYoo8RDwJrU+qXkjWtfi8Xxt58BdQuwQs9qC/afLwCw8tnQbqYAPsgxE1S6F3EAIXux2oQFKm0ihMsOF71dHYx+f3NND68ghCu1YIoePPQN1pGRABkJ6Bus96CutRZMydTl+TvuiRW1m3n0eDl0vRPcEysqdXn+jsQPsrHMquGeXEaY4Yk4wxWcY5V/9scqOMOVUFthatyTy8QyqwZ+kDURKoMWxNKr2EeqVKcTNOajqKoBgOE28U4tdQl5p5bwCw7BWquaZSzAPlwjlithJtp3pTImSqQRrb2Z8PHGigD4RZuNX6JYj6wj7O4TFLbCO/Mn/m8R+h6rYSUb3ekokRY6f/YukArN979jc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m3n0eDl0vRPcEysqdXn+jsQPsrHMquGeXEaY4Yk4wxWcY5V/9scqOMOVUFthatyTy8QyqwZ+kDURKoMWxNKr2EeqVKcTNOajqKoBgOE28U4tdQl5p5bwCw7BWquaZSzAPlwjlithJtp3pTImSqQRrb2Z8PHGigD4RZuNX6JYj6wj7O4TFLbCO/Mn/m8R+h6rYSUb3ekokRY6f/YukArN979jcW+V/S8g0eT/N3VN3kTqWbQ428m9/8k0P/1aIhF36PccEl6EhOcAUCrXKZXXWS3XKd2vc/TRBG9O5ELC17MmWubD2nKhUKZa26Ba2+D3P+4/MNCFwg59oWVeYhkzgN/JDR8deKBoD7Y+ljEjGZ0sosXVTvbc6RHirr2reNy1OXd6pJsQ+gqjk8VWFYmHrwBzW/n+uMPFiRwHB2I7ih8ciHFxIkd/3Omk5tCDV1t+2nNu5sxxpDFNx+huNhVT3/zMDz8usXC3ddaHBj1GHj/As08fwTS7Kt1HBTmyN29vdwAw+/wbwLVOJ3uAD1wi/dUH7Qei66PfyuRj4Ik9is+hglfbkbfR3cnZm7chlUWLdwmprtCohX4HUtlOcQjLYCu+fzGJH2QRKvP3UNz8bWk1qMxjGTOMThZ3kvgLI5AzFfo379UAAAAASUVORK5CYII=\"\r\nbase64imgcv = open_image_in_cv(base64img)\r\nbase64img2cv = open_image_in_cv(base64img2)\r\nbase64imgcv = open_image_in_cv(base64img, channels_in_output=4)\r\nbase64img2cv = open_image_in_cv(base64img2, channels_in_output=4)\r\nbase64imgcv = open_image_in_cv(base64img, channels_in_output=2)\r\nbase64img2cv = open_image_in_cv(base64img2, channels_in_output=2)\r\n\r\n#urls\r\npininterestlogo = \"https://camo.githubusercontent.com/7f81f312b05694ccc8cd29e3c3466945ff8e73a13320d3fd0f90c6915bbb4ffb/68747470733a2f2f63646e2e6a7364656c6976722e6e65742f67682f646d68656e647269636b732f7369676e61747572652d736f6369616c2d69636f6e732f69636f6e732f726f756e642d666c61742d66696c6c65642f353070782f70696e7465726573742e706e67\"\r\nlinkcv1 = open_image_in_cv(pininterestlogo)\r\nlinkcv2 = open_image_in_cv(pininterestlogo, channels_in_output=4)\r\nlinkcv3 = open_image_in_cv(pininterestlogo, channels_in_output=2)\r\nlinkcv4 = open_image_in_cv(pininterestlogo, channels_in_output=3)\r\n\r\n#bytes/raw data\r\nbyteimage = base64.b64decode(base64img2)\r\nbyteimage1 = open_image_in_cv(byteimage)\r\nbyteimage2 = open_image_in_cv(byteimage, channels_in_output=4)\r\nbyteimage3 = open_image_in_cv(byteimage, channels_in_output=2)\r\nbyteimage4 = open_image_in_cv(byteimage, channels_in_output=3)\r\n\r\n#PIL\r\npilimage = Image.fromarray(byteimage2)\r\npilimage1 = open_image_in_cv(pilimage)\r\npilimage2 = open_image_in_cv(pilimage, channels_in_output=4)\r\npilimage3 = open_image_in_cv(pilimage, channels_in_output=2)\r\npilimage4 = open_image_in_cv(pilimage, channels_in_output=3)\r\n\r\n#float images to np.uint8\r\nfloatimage = pilimage4.astype(float)\r\nfloatimage1 = open_image_in_cv(floatimage)\r\nfloatimage2 = open_image_in_cv(floatimage, channels_in_output=4)\r\nfloatimage3 = open_image_in_cv(floatimage, channels_in_output=2)\r\nfloatimage4 = open_image_in_cv(floatimage, channels_in_output=3)\r\n\r\n#filepath\r\nfilepath = \"c:\\\\testestestes.png\"\r\npilimage.save(filepath)\r\nfilepath1 = open_image_in_cv(filepath, bgr_to_rgb=True)\r\nfilepath2 = open_image_in_cv(filepath, channels_in_output=4, bgr_to_rgb=True)\r\nfilepath3 = open_image_in_cv(filepath, channels_in_output=2, bgr_to_rgb=True)\r\nfilepath4 = open_image_in_cv(filepath, channels_in_output=3, bgr_to_rgb=True)\r\n\r\n\r\nfrom a_cv2_imshow_thread import add_imshow_thread_to_cv2\r\nadd_imshow_thread_to_cv2()\r\ncv2.imshow_thread(\r\n [\r\n base64imgcv,\r\n base64img2cv,\r\n linkcv1,\r\n linkcv2,\r\n linkcv3,\r\n linkcv4,\r\n byteimage1,\r\n byteimage2,\r\n byteimage3,\r\n byteimage4,\r\n pilimage1,\r\n pilimage2,\r\n pilimage3,\r\n pilimage4,\r\n floatimage1,\r\n floatimage2,\r\n floatimage3,\r\n floatimage4,\r\n filepath1,\r\n filepath2,\r\n filepath3,\r\n filepath4,\r\n ]\r\n)\r\n Parameters:\r\n image:Any\r\n Can be URL, bytes, base64, file path, np.ndarray, PIL\r\n channels_in_output:Union[int,None]\r\n None (original image won't be changed)\r\n 2 (GRAY)\r\n 3 (BGR)\r\n 4 (BGRA)\r\n (default=None)\r\n bgr_to_rgb:bool=False\r\n Converts BGRA to RGBA / BGR to RGB\r\n Returns:\r\n image:np.ndarray\r\n (Always as np.uint8)\r\n```\r\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Less trouble reading/writing images with OpenCV (from url/path/buffer/base64...)",
"version": "0.13",
"project_urls": {
"Homepage": "https://github.com/hansalemaos/a_cv_imwrite_imread_plus"
},
"split_keywords": [
"opencv",
"cv2",
"numpy",
"cv"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "1077614e2d7f17ce7265c7ac4b2988bc85fa3d2f57c69c1cd148042cef051911",
"md5": "7981c213f4ea023d9704d038bfeec935",
"sha256": "1a79c51dc30b8f9b82673737ea2463df3621d49d9edfef8a65dde58e787dbc00"
},
"downloads": -1,
"filename": "a_cv_imwrite_imread_plus-0.13-py3-none-any.whl",
"has_sig": false,
"md5_digest": "7981c213f4ea023d9704d038bfeec935",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 80054,
"upload_time": "2023-08-14T17:50:48",
"upload_time_iso_8601": "2023-08-14T17:50:48.175651Z",
"url": "https://files.pythonhosted.org/packages/10/77/614e2d7f17ce7265c7ac4b2988bc85fa3d2f57c69c1cd148042cef051911/a_cv_imwrite_imread_plus-0.13-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "7b92a8aaac221e8a5d21da57e88ef6f7c6cda0d24ad1d89f2576987f17f6bf92",
"md5": "3a7dbe77a23ca41397155a341d142f89",
"sha256": "75448661c378305630c5fdd6248388b83b90fbd2779fed3e1be219bef6da2a5e"
},
"downloads": -1,
"filename": "a_cv_imwrite_imread_plus-0.13.tar.gz",
"has_sig": false,
"md5_digest": "3a7dbe77a23ca41397155a341d142f89",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 78946,
"upload_time": "2023-08-14T17:50:50",
"upload_time_iso_8601": "2023-08-14T17:50:50.081334Z",
"url": "https://files.pythonhosted.org/packages/7b/92/a8aaac221e8a5d21da57e88ef6f7c6cda0d24ad1d89f2576987f17f6bf92/a_cv_imwrite_imread_plus-0.13.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-08-14 17:50:50",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "hansalemaos",
"github_project": "a_cv_imwrite_imread_plus",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"requirements": [],
"lcname": "a-cv-imwrite-imread-plus"
}