Hello guest, if you read this it means you are not registered. Click here to register in a few simple steps, you will enjoy all features of our Forum.
Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
merge drawings
#1
I'm writing a program that makes a png file by combining two other png files.

It's joining them together but not quite the way I want it to. It joins drawing 'A' (which is a transperancy) and places it on drawing 'B'. The end result is drawing 'C' which is not what I want. I want it to look like drawing 'D'. Cry

http://content.screencast.com/users/dchr...70/bug.png

Which drawings to merge together are specified on bres config bargraph.csv lines 5 and 16. The x and y coordinates of where to place image A onto image B is specified on lines 18 and 19

The filename of what to call this new drawing is specified on line 6


Bres data.csv is for future use. Ignore it





My code

import csv
import sys

from PIL import Image, ImageDraw, ImageFont # COMMNAD FOR INSTALL PIL sudo apt-get install python-dev libjpeg-dev libfreetype6-dev zlib1g-dev
# $ sudo pip install pil

data =
#read data file.
dataf = None
configf = None

try:
dataf = open('bres data.csv', 'rt')
configf = open('bres config bargraph.csv', 'rt')

data = [d for d in csv.reader(dataf)]
all_config = [c for c in csv.reader(configf)]

image = Image.open(all_config[5][0])
width, height = image.size


image.paste(Image.open(all_config[16][0]), (int(all_config[18][0]),int(all_config[19][0])))



image.save(all_config[6][0])
print "%s file ready"%all_config[6][0]

except Exception, e:
print "Error Encountered: ",e
finally:
if dataf:
dataf.close()
if configf:
configf.close()
buran wrote Oct-12-2017, 07:02 AM:
Please, use proper tags when post code, traceback, output, etc.
See BBcode help for more info.
Please, repost with code in code tags.
Quote
#2
You should use pillow instead as that is the new pil.

I usually dont post links to SO but it would depend on a few factors. And this thread already contains each solution depending on which of your images has an alpha channel, and im on a tablet now...
https://stackoverflow.com/questions/5324...-using-pil
Quote
#3
I have temporarily changed this line. It still does the same thing only it is easier to follow

image.paste(Image.open('bres sc4.png'), (int(300),int(400)))
i think that I have to change this to:

image.paste(Image.open('bres sc4.png'), (int(300),int(400), mask='bres sc4.png')))

Is this correct? I tried it and get an error

BTW I'm not ignoring this request, I just don't know how

Please, use proper tags when post code, traceback, output, etc.

Sorry what I meant to say is, Am I on the right track? Will you help me with this line?
sparkz_alot wrote Oct-13-2017, 01:51 PM:
buran included the link, and I will repeat it here BBCode Help. "I just don't know how" is not an acceptable excuse.
Quote
#4
This program makes a drawing by merging two drawings together but not quite the way I want it to. It joins drawing 'A' (which is a transparency) and places it on drawing 'B'. The end result is drawing 'C' which is not what I want. I want it to look like drawing 'D'.

http://content.screencast.com/users/dchr...70/bug.png

This is my line of code


image.paste(Image.open('bres sc4.png'), (int(300),int(400)))
I searched the web and think that I found the problem. I need to specify the 3rd parameter. However, I don't know how.

I think it needs to be something like this but this gives me an error


image.paste(Image.open('bres sc4.png'), (int(300),int(400)), mask='bres sc4.png'))
Quote

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  [split] merge/display values from two dictionaries ramkumar_70 3 86 Oct-17-2017, 09:42 PM
Last Post: DeaD_EyE
  merge files AGC 4 74 Oct-04-2017, 08:54 PM
Last Post: AGC
  How to merge different columns of date into a single column sujai_banerji 1 61 Sep-26-2017, 07:13 PM
Last Post: buran
  Merge Predictions with whole data set mayanksrivastava 0 145 Jun-29-2017, 11:39 AM
Last Post: mayanksrivastava
  Pandas merge question smw10c 1 331 May-05-2017, 09:57 PM
Last Post: zivoni
  PyPDF2, merge.append(...) problem peterkl 1 780 Oct-23-2016, 09:50 AM
Last Post: peterkl

Forum Jump:


Users browsing this thread: 1 Guest(s)