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 :: write list to csv python 
Python :: how to make python 3 default on mac 
Python :: dense layer keras 
Python :: python unittest discover 
Python :: tkinter toplevel 
Python :: multiline comment in python 
Python :: pretty printing using rich library in python 
Python :: python casting 
Python :: tkinter treeview 
Python :: Get the square root of a number in Python 
Python :: numpy fill with 0 
Python :: python slit 
Python :: pytest local modules 
Python :: how to declare np datetime 
Python :: pandas filter rows by value 
Python :: how to detect the reaction to a message discord.py 
Python :: get median using python 
Python :: python code execution time 
Python :: python qt always on top 
Python :: what is tensor in deep learning 
Python :: take first 10 row while reading csv python 
Python :: pytorch version python command 
Python :: r named chr to dataframe 
Python :: Create chatbot in Python - Source: NAYCode.com 
Python :: Python message popup 
Python :: python lists 
Python :: how to change the disabled color in tkinter 
Python :: display multiple dataframe as table jupyter notebook 
Python :: make a new environment conda 
Python :: tkinter include svg in script 
ADD CONTENT
Topic
Content
Source link
Name
3+4 =