Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

python cv2 imwrite

# Python program to explain cv2.imwrite() method
  
# importing cv2 
import cv2
  
# importing os module  
import os
  
# Image path
image_path = r'C:UsersRajnishDesktopGeeksforGeeksgeeks.png'
  
# Image directory
directory = r'C:UsersRajnishDesktopGeeksforGeeks'
  
# Using cv2.imread() method
# to read the image
img = cv2.imread(image_path)
  
# Change the current directory 
# to specified directory 
os.chdir(directory)
  
# List files and directories  
# in 'C:/Users/Rajnish/Desktop/GeeksforGeeks'  
print("Before saving image:")  
print(os.listdir(directory))  
  
# Filename
filename = 'savedImage.jpg'
  
# Using cv2.imwrite() method
# Saving the image
cv2.imwrite(filename, img)
  
# List files and directories  
# in 'C:/Users / Rajnish / Desktop / GeeksforGeeks'  
print("After saving image:")  
print(os.listdir(directory))
  
print('Successfully saved')
Comment

cv2 imwrite

cv2.imwrite(filename, img) # BGR 
Comment

cv2.imwrite

# importing cv2 
import cv2
# Image path
image_path = "PATH2IMAGE"
# Using cv2.imread() method to read the image
img = cv2.imread(image_path) 
# New Filename
filename = 'savedImage.jpg'
# Using cv2.imwrite() method Saving the image
cv2.imwrite(filename, img)
Comment

PREVIOUS NEXT
Code Example
Python :: is in python 
Python :: python sum 
Python :: defaultdict initialize keys 
Python :: absolute url 
Python :: slice in python 
Python :: remove file os python 
Python :: gensim show_topics get topic 
Python :: replace multiple column values pandas 
Python :: randomly pick a value in the list 
Python :: matplotlib draw line x1, y1 
Python :: how to install python library 
Python :: muliline comment in pyhton 
Python :: create python executable 
Python :: python scipy moving average 
Python :: Swap first and last list elements 
Python :: how to redirect user in flask response python 
Python :: raw input example python 
Python :: why a Python Arithmetic Operators used 
Python :: max deviation in pandas 
Python :: add 1 to all columns in numpy array 
Python :: python list deep copy 
Python :: python add 1 to 100 
Python :: numpy indexing arrays 
Python :: group by month and day pandas 
Python :: python tkinter messagebox 
Python :: concatenation array 
Python :: python dictionary pop key 
Python :: username python 
Python :: pronic number program in python 
Python :: table in sqlite python 
ADD CONTENT
Topic
Content
Source link
Name
9+6 =