Spaces:
Paused
Paused
Download utils/image_io.py from MBG0903/Saree-Design-App: direct link, hf CLI and curl.
- Browser
- Download file 580 Bytes
-
https://huggingface.co/spaces/MBG0903/Saree-Design-App/resolve/main/utils/image_io.py
- Command line
-
hf download hf://spaces/MBG0903/Saree-Design-App/utils/image_io.py
-
curl -L -o image_io.py https://huggingface.co/spaces/MBG0903/Saree-Design-App/resolve/main/utils/image_io.py
580 Bytes
| import cv2 | |
| import tempfile | |
| def save_png(img): | |
| temp = tempfile.NamedTemporaryFile( | |
| delete=False, | |
| suffix=".png" | |
| ) | |
| cv2.imwrite( | |
| temp.name, | |
| cv2.cvtColor( | |
| img, | |
| cv2.COLOR_RGB2BGR | |
| ) | |
| ) | |
| return temp.name | |
| def save_bmp(img): | |
| temp = tempfile.NamedTemporaryFile( | |
| delete=False, | |
| suffix=".bmp" | |
| ) | |
| cv2.imwrite( | |
| temp.name, | |
| cv2.cvtColor( | |
| img, | |
| cv2.COLOR_RGB2BGR | |
| ), | |
| [cv2.IMWRITE_BMP_COMPRESSION, 0] | |
| ) | |
| return temp.name |