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 :: convert csv file into python list 
Python :: count most frequent words in list python 
Python :: bs4 class 
Python :: iterate over classes in module python 
Python :: draw circle pygame 
Python :: python filter timestamp 
Python :: how to take input for list in one line in python 
Python :: django deployment 
Python :: python projects with source code 
Python :: kill and run process in windows python 
Python :: primary key auto increment python django 
Python :: Python NumPy broadcast_to() Function Example 
Python :: how to unlist a list in python 
Python :: Custom x, y-ticks using plt 
Python :: python integer to string 
Python :: python os get path 
Python :: group by pandas count 
Python :: requests python3 example 
Python :: python create a grid of points 
Python :: python strip 
Python :: Python string to var 
Python :: length of string python 
Python :: check if string contains python 
Python :: python append csv to dataframe 
Python :: factorial of a number in python 
Python :: factors for negative number python 
Python :: python extract list from string 
Python :: numpy remove nan rows 
Python :: pygame mixer documentation 
Python :: rotate matrix python 
ADD CONTENT
Topic
Content
Source link
Name
9+3 =