Open In App

pgmagick| creating color backgrounds

Improve
Improve
Like Article
Like
Save
Share
Report

In this article we will learn how we can create a background with a solid color. We can use these backgrounds in our output image backgrounds. Also we will how to create transparent and backgrounds with color gradients. 
For eg: 
 

Here in the above image green us the background color of GeeksforGeeks logo so lets start with the code.
1. Solid Background : 
Now lets create a background with solid green color. 
Code : 
 

Python3




from pgmagick.api import Image
 
img = Image((300, 300), 'green')
img.write('green.jpg')


Output : 
 

2. Transparent Background : 
Now lets create a Transparent background. 
Code : 
 

Python3




from pgmagick.api import Image
 
img = Image((300, 300), 'transparent')
img.write('transparent.jpg')


Output : 
 

2. Gradient Background : 
Now lets create a background with some color gradient. 
Code : 
 

Python3




from pgmagick.api import Image
 
img = Image((300, 200), 'gradient:# 318749-# 0eed4c')
img.write('gradient.jpg')


Output :
 

 



Last Updated : 16 Feb, 2022
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads