Last active
October 26, 2022 14:05
-
-
Save qingswu/1a58c9d66dfc0a6aaac45528bbe01b82 to your computer and use it in GitHub Desktop.
Convert all png images in current folder to jpg using OpenCV cv2
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
#!/usr/bin/env python | |
from glob import glob | |
import cv2 | |
pngs = glob('./*.png') | |
for j in pngs: | |
img = cv2.imread(j) | |
cv2.imwrite(j[:-3] + 'jpg', img) |
@ghost you just have to give the folder name in cv.imwrite before the file name .
e.g. 'jpg_images/'+j[:-3] + 'jpg'
I found same strange bug and using this script. I try to convert 4k image png(sizes almost 40mb) to jpg.
color image but Normal map image works fine.
I think first image conversion has error other are fine atleast to my eye vision.
if any one notices difference in below images too , plz kindly report by commenting.
thank you in advance.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi @qingswu, do you know what changes can be made in this algorithm if we want to save all the jpgs ina different folder? Could you let me know.