OpenCV Writing Images

OpenCV Writing Images In Hindi

Python OpenCV

OpenCV Writing Images In Hindi – OpenCV Me imwrite Method Ka Use Kar Ke Aap Kisi Image Ke format Ko Change Kar Sakte Hai. JPG to Png, Png to Jpg, Jpg to Jpg, etc.

Agar Aap OpenCV Ko Poora A-Z Learn Karna Chahte Hai To Aapko, Sabse Pahle Aapko OpenCV Ke Previous Post Ko Read Karna Chahiye – Opencv Setup And Installation In Hindi

OpenCV Writing Images In Hindi

OpenCV Me Kisi Image Ko Write Karne Ke Liye imwrite method Ka Use Karna Padta Hai. Is Method Ka Use Karke Aap Image format Ko Change Kar Sakte Hai.

Ex- jpg -> Png or Png -> Jpg

Image Format Change Hone Ke Baad New Image Format Aapne Aap Hi Folder Me Save Ho Jata Hai.

OpenCV Me Image Ko Folder Me Save Karne Ke Liye imwrite method Ka Bahut Istemal Hota Hai.

Example 1Convert PNG To JPG OR JPG To JPG

Folder before Program Run

Is Example Me Ham Convert JPG To PNG OR Convert JPG To JPG Karne Wale Hai |

Upar Diye Hue Image Me Aap Dekh Sakte Hai Ki Folder Me Only 2 Files Hai main.py and master.jpg

  • main.py Python File Hai Jisme Program Ko Likha Jayega
  • master.jpg Image Hai Jiske par imwrite method Ka Use Kiya Jayega.
import cv2

img = cv2.imread('Master.jpg')

cv2.imwrite('Masterprogramming.jpg',img)
cv2.imwrite('Masterprogramming.png',img)

STEP 1 = Sabse Pahle cv2 Ko import kiya

STEP 2 = img Variable me Master.jpg ko imread kiya

STEP 3 = Master.jpg ko Masterprogramming.jpg Ke Format Me Save Kiya. (jpg -> jpg)

STEP 4 = Master.jpg ko Masterprogramming.png Ke Format Me Save kiya. (jpg -> png)

Folder After Program Run

Aap Dekh Sakte Hai Program Ke Run Hone Ke Baad Two More Image Save Ho Gaye Hai. Masterprogramming.jpg and Masterprogramming.png.

EXAMPLE 2Convert JPG To PNG

Folder before program run

Upar Diye Hue Image Me Aap Dekh Sakte Hai Ki Folder Me Only 2 Files Hai main.py and website.jpg

import os
import cv2

img_path = r'C:\Users\omprakash\Desktop\hello python\website.jpg'

img = cv2.imread(img_path)

filename = 'Saved.jpg'
filename1 = 'Jpg to Png Image.png'

cv2.imwrite(filename,img)
cv2.imwrite(filename1,img)

STEP 1 = Sabse Pahle os And cv2 Ko import Kiye

STEP 2 = img_path Variable Bana Kar Usme r Likhne Ke Baad Image Ke Path Ko Paste Kiya

STEP 3 = img Variable Me cv2.imread Method Ka Use Kiya And img_path Variable Ko Parameter me Pass Kar Diya

STEP 4 = filename And filename1 Two Variable Banaya And New Image Name and Uske Format Ko Likha (Saved.jpg and Jpg to Png Image.png )

STEP 5 = cv2.imwrite(filename,img) method Me First Parameter Me New Variable and Second Parameter Me Original Image ko pass kare.

Folder After Program Run

Friends Mujhe Umeed Hai Ki Aapko OpenCV Writing Image In Hindi Ke Bare Mai 100% Jankari Ho Gayi Hogi | Agar Aapko Learn Karne Main Dikkat Aa Rahi Hai To Aap Mere Se Contact Kar Sakte Hai.

Leave a Reply

Your email address will not be published. Required fields are marked *