Hi, I'm trying to use the function paste() to paste a image into another image but I can't get it work! Is it the right function to use or is there any other function that's better?
Here's my very simple code: -
from PIL import Image
-
import ImageDraw
-
-
im = Image.new("RGB", (500,500), "white")
-
draw = ImageDraw.Draw(im)
-
-
icon = Image.open("icon1.jpg")
-
im.paste(icon, (0,0,86,62))
-
-
del draw
-
im.save("test.jpg", "JPEG")
and the message: - Traceback (most recent call last):
-
File "C:\Program Files\Eclipse 3.2.2\plugins\org.python.pydev.debug_1.3.4\pysrc\pydevd.py", line 754, in <module>
-
debugger.run(setup['file'], None, None)
-
File "C:\Program Files\Eclipse 3.2.2\plugins\org.python.pydev.debug_1.3.4\pysrc\pydevd.py", line 597, in run
-
execfile(file, globals, locals) #execute the script
-
File "C:\Documents and Settings\eviceng\My Documents\Python\cellTestare\src\paste.py", line 8, in <module>
-
im.paste(icon, (0,0,86,62))
-
File "C:\Python25\Lib\site-packages\PIL\Image.py", line 1076, in paste
-
self.im.paste(im, box)
-
ValueError: images do not match
/flaerpen
1 17709
Hi, I'm trying to use the function paste() to paste a image into another image but I can't get it work! Is it the right function to use or is there any other function that's better?
Here's my very simple code: -
from PIL import Image
-
import ImageDraw
-
-
im = Image.new("RGB", (500,500), "white")
-
draw = ImageDraw.Draw(im)
-
-
icon = Image.open("icon1.jpg")
-
im.paste(icon, (0,0,86,62))
-
-
del draw
-
im.save("test.jpg", "JPEG")
and the message: - Traceback (most recent call last):
-
File "C:\Program Files\Eclipse 3.2.2\plugins\org.python.pydev.debug_1.3.4\pysrc\pydevd.py", line 754, in <module>
-
debugger.run(setup['file'], None, None)
-
File "C:\Program Files\Eclipse 3.2.2\plugins\org.python.pydev.debug_1.3.4\pysrc\pydevd.py", line 597, in run
-
execfile(file, globals, locals) #execute the script
-
File "C:\Documents and Settings\eviceng\My Documents\Python\cellTestare\src\paste.py", line 8, in <module>
-
im.paste(icon, (0,0,86,62))
-
File "C:\Python25\Lib\site-packages\PIL\Image.py", line 1076, in paste
-
self.im.paste(im, box)
-
ValueError: images do not match
/flaerpen
I got this from the PIL website: -
im.paste(image, box)
-
-
Pastes another image into this image. The box argument is either a 2-tuple giving the upper left corner, a 4-tuple defining the left, upper, right, and lower pixel coordinate, or None (same as (0, 0)). If a 4-tuple is given, the size of the pasted image must match the size of the region.
-
So either give a 2-tuple or make the coordinates match icon.jpg's.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: jean-Baptiste Cazier |
last post by:
Sæl !
I am trying to rotate some text and paste it into a larger PIL Image.
( cannot use PyFT for some reasons)
However I have a problem of transparency and my new images in a box
shape are...
|
by: Caleb Hattingh |
last post by:
Here's hoping effbot is around :)
I have a really simple situation where I have 2 png images, and open them
so:
'>>> iconBallImage =...
|
by: James |
last post by:
I'm very interested to hear if anyone has created an access database
that enables a user to cut and paste an image from a web page into a
database.
The database then stores the image and then...
|
by: MLH |
last post by:
I have a logo image that I can paste into MS Paint as an image with
clear background. Think of the logo as a black circle in a white,
rectangular background. When I paste into Paint, the white...
|
by: Scott Friedrich |
last post by:
Hi group
I am using a 3rd party AX control in a VB.NET application. One of the methods of this control is to capture the current map within the control to the windows clipboard as .WMF. I am...
|
by: lgbjr |
last post by:
Hello All,
I¡¯m using a context menu associated with some pictureboxes to provide
copy/paste functionality. Copying the image to the clipboard was easy. But
pasting an image from the clipboard...
|
by: Peter Bengtsson |
last post by:
I love the dropshadow effect I managed to make with this recipe:
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/474116
Here's what it can look like:...
|
by: Durand |
last post by:
Hi!
I'm trying to paste a png with a transparent layer into an image using "image.paste(tesla,(20,10), tesla)" but I'm getting this error:
ValueError: bad transparency mask
I have used...
|
by: crapycoder |
last post by:
hi all, please help....!!
i have added a kodak image edit control on my form.
when i click get image button,
"abc.img" will be displayed.
i have a button named "copy to clipboard".
when...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
| |