Python + cv2 exercises to resize jpg and save in bmp
Python + cv2 exercises to resize jpg and save in bmp, tested on Raspberry Pi 5/64 bit Raspberry Pi OS (bookworm). py_cv_resize.py , resize jpg and save in bmp, the file name is hard-coded in the program. You can also save the image in other file name/format in cv.imwrite() interface. # Python exercise to resize jpg and save in bmp # tested on Raspberry Pi 5/64 bit Raspberry Pi OS (bookworm) import cv2 as cv target_width = 240 target_height = 240 path = "./images/" file = "05" ext_jpg = ".jpg" ext_bmp = ".bmp" img = cv.imread(path + file + ext_jpg) img = cv.resize(img, (target_width, target_height)) cv.imwrite(path + file + ext_bmp, img) cv.imshow("img", img) cv.waitKey(0) cv.destoryAllWindows() py_cv_batch_resize.py , resize in batch. It's used to prepare bmp images in my next " Adafruit_GFX/ImageReader exercises to load bmp images from MicroSD and display on 240×320 ST7789 SPI TFT, run on Seeed Studio XIAO