Personalised Jpegs for emailed wedding invitations

Let’s say you want to invite a bunch of people to your wedding and your soon-to-be-spouse wants some nice graphic you can mail to folks that has their name in it. You can do this! This script works with Linux and should work with OS X. It will require a few changes to work with windows.

Install some nifty software

I’m using both imagemagick and OptiPNG, both of which I got through apt-get. Probably, the png step is overkill and you could go straight to jpeg.
I’m also using Inkscape, Python and LibreOffice, but you can use any spreadsheet you want.

Make the graphic template

  1. Find some nice border of some kind. I drew one and scanned it, but there are other options.
  2. Open your nice border in inkscape (or other svg editor).
  3. Put all the text you want into your graphic, with the font you want.
  4. In the part where you want their name, put GUEST_NAME
  5. Save your lovely creation as template.svg

Compile names and email addresses

In LibreOffice, open a new spreadsheet and make a bunch of entries for your guests.
The first column should be email addresses.
If you are NOT saving the images, then the next column can all say ‘invite’ for every single entry. If you want to save the jpegs (say to post them to facebook walls as well as emailing them), then give them a short name associated with the person. This will be a file name, so it should be all one word that starts with a letter and contains only letters, numbers and underscores.
The last column should be the name you want to appear in the invite. You know from making your template how much space you have for names, so keep that in mind, if you’re deciding to put in Reverend Doctor Julius Milliband Cameron III’s full name or not. Or you may need to go back and tweak your template.
Your speadsheet should look something like this:

foo@example.com jen Jennifer
bar@example.com ralph Ralph & Morris
dr_rev@example.com ju Dr Cameron

Save this spreadsheet as guests.csv

The script

Get ready

Save your template, your spreadsheet and the script (cut and past from below), all to the same folder on your system. Call the script doemail.py
You will need to modify this script a bit.
Put in your own text where you see the part that says YOUR OWN TEXT. You’ll see it asks for your own text twice. One of those times is plain text. The other one is HTML. the plain text one is just text. Don’t include any html tags. If you put in links, you just have to put in the link as plain text. In the HTML part, you can use a lot of markup, including <a href=”blah.com”>blahblah</a> tags and whatnot. You can do inline CSS, if you like, but it’s email, so keep it relatively simple. In both sections, don’t forget to include a link to your website. And if you are using an online form for RSVPs, link to that as well.
You’ll also need to put in your own email address, and your own password. If you are using gmail, you can use an application-specific password.
Finally, you will also need to put in the smpt server for your mail server. Near the top of the file, you’ll see lines for hotmail and gmail. Delete any that don’t apply to you. If you are using a different server, you’ll have to find out what to put there.
If you want to save the nice jpegs, say to also post them in facebook messages, then look for the line:

jpegname = "/tmp/"+name+".jpeg"

and change the ‘/tmp/’ part to another directory on your system.
You need to make the script executable. Open the terminal application and cd to the directory with the script, template, and spreadsheet. Type:

 chmod +x doemail.py

This will make the script executable as a program you can run. then, double check your spreadsheet is ok. Type:

less guests.csv

It should look like:

foo@example.com,jen,Jennifer
bar@example.com,ralph,Ralph & Morris
dr_rev@example.com,ju,Dr Cameron

If you see semicolons instead of commas, then you need to change your script to tell it that. Change

guestreader = csv.reader(csvfile)

to

guestreader = csv.reader(csvfile, delimiter=';')

To run the script, still from your terminal, type:

 ./doemail.py

The Actual script to cut and paste

#! /usr/bin/python

import smtplib
import re
import subprocess
import os
import cgi
import uuid
import csv

from subprocess import call
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
from email.mime.image import MIMEImage
from email.mime.multipart import MIMEMultipart
from email.mime.text      import MIMEText
from email.mime.image     import MIMEImage
from email.header         import Header    



# me == my email address
me = "example@hotmail.co.uk"
password = "yourEmailPassword"
smpt_server = "smtp.live.com:587" #hotmail
smpt_server = "smtp.gmail.com:587" #gmail

with open('guests.csv') as csvfile:
    guestreader = csv.reader(csvfile)
    for row in guestreader:
        you = row[0]
        name = row[1]
        salutation = row[2]

        name = ''.join(name.split())



        text = "Dear " + salutation + ",nn  YOUR TEXT GOES HERE http://YOURWEBSITE.COM"


        html = """
<html>
  <head></head>
  <body>
    <p>
<a href="YOUR WEDDING WEBSITE">
        """
        html = html + "<img src="cid:{}@example.com" alt="[More Information]" /></a></p>n<p>Dear {},</p>".format(img['cid'], salutation)
        html = html + """
<p>YOUR TEXT GOES HERE</p>
</body></html>
    </p>
  </body>
</html>
        """


        print (salutation)

        # Create message container - the correct MIME type is multipart/alternative.
        msg = MIMEMultipart('related')
        text_msg = MIMEMultipart('alternative')
        msg['Subject'] = Header(u'Wedding Invitation', 'utf-8')
        msg['From'] = me
        msg['To'] = you



        # make the image

        filename = "/tmp/"+name+".svg"
        pngname = "/tmp/"+name+".png"
        jpegname = "/tmp/"+name+".jpeg"

        svg = open("template.svg");
        svgn = open(filename, 'w');
        lines = svg.read().split('n')
        for line in lines:
            line = re.sub('GUEST_NAME',re.sub('&', '&amp;', salutation), line)
            svgn.write(line)
        #endfor

        svg.close()
        svgn.close()

        os.system("inkscape -f " + filename + " -e " + pngname)
        os.system("optipng " + pngname);
        os.system("convert -compress JPEG -quality 87 " + pngname + " " + jpegname);

        os.system("rm " + filename)

    
        # attach the image to the email

        img = dict(title=u'Invitation', path=jpegname, cid=str(uuid.uuid4()))
                                                        #cid=name)
                                                        #cid=str(uuid.uuid4()))
        with open(img['path'], 'rb') as file:
            msg_img = MIMEImage(file.read(), name=os.path.basename(img['path']))
            #msg.attach(msg_img)
            msg_img.add_header('Content-ID', '<{}@example.com>'.format(img['cid']))
            msg_img.add_header('Content-Name', img['cid'])
            msg_img.add_header('X-Attachment-ID', '{}@example.com'.format(img['cid']))
            #msg_img.add_header('Content-Disposition', 'attachment', filename=os.path.basename(img['path']))
            msg_img.add_header('Content-Disposition', 'inline', filename=os.path.basename(img['path']))

        print('<{}>'.format(img['cid']))



        # Create the body of the message (a plain-text and an HTML version).



        # Record the MIME types of both parts - text/plain and text/html.
        part1 = MIMEText(text, 'plain')
        part2 = MIMEText(html, 'html')

        # Attach parts into message container.
        # According to RFC 2046, the last part of a multipart message, in this case
        # the HTML message, is best and preferred.
        text_msg.attach(part1)
        text_msg.attach(part2)
        msg.attach(text_msg)
        msg.attach(msg_img)


        # Send the message via local SMTP server.
        server = smtplib.SMTP(smpt_server)
        server.ehlo()
        server.starttls()
        server.login(me,password)
        # sendmail function takes 3 arguments: sender's address, recipient's address
        # and message to send - here it is sent as one string.
        server.sendmail(me, you, msg.as_string())
        server.close()
        #server.quit()

        os.system("rm " + pngname)

    #end for (going through rows in the database)
    csvfile.close()
#end with    

I’m using Firefox because it’s great in programming and politics

Update: Eich has stepped down.
Yeah, so OkCupid says I should switch to a Google product because it’s better on LGBT rights. Um, have they been paying attention to anything? The new Mozilla CEO gave $1k to overturn marriage quality in California, whereas Google sponsored a national conference of prominent right-wing politicians who want to overturn all LGBT rights everywhere.
You know what, I love having equal marriage rights in California, really I do. And like most LGBT people, I thought prop 8 was terrible. But what I don’t like is ‘pink washing’, where some company makes some lame claim to be a sponsor of LGBT rights, (usually by having a health insurance policy that is vaguely equal or, thse days, by supporting something that a large majority of American agree with anyway (how bold!)) and then we’re supposed to forgive them all their other sins. Even if Google weren’t sponsoring CPAC, they’d still be in bed with the NSA.
We don’t hear much about ‘don’t be evil’ these days, because, alas, Google is making a fuckload of money by being evil. Mozilla never needed a corporate slogan like that because their mission has always been to do good from the very outset. I agree with this queer Mozilla employee who doesn’t want the open internet to get caught up in the American political football match of left vs right wedge issues and distraction. Open internet and NSA spying is more important than a relative small donation to an odious cause, which, by the way, does not mean we should be ‘tolerant’ of some asshole’s concrete political actions to take away rights from a minority which includes some of this own employees. If every other browser was also open source and pro-open standards and on the right side of LGBT rights, then this would be worth switching browsers over, for sure, but that’s not what’s going on here. The CEO says he won’t resign, which is a poor choice, but, again, really not worth a boycott. Especially when the other choices are closed source or blatantly on the side of evil.
So keep Firefox, and install Lightbeam if you want to see just how bloody much Google is spying on your every move. And if you’re an ally or whatever like OKCupid, how about doing a tiny bit of research and not telling LGBT people what to think or do? LGBT people and Mozilla employees can all speak for themselves/ourselves. Because, hey, we’ve got the internet, which is still open, thanks largely to the efforts of Mozilla.
Disclaimers of various sorts: I used to work for Netscape and I got the first same sex divorce in the state of California.

Bullying as Journalism

EDIT: ESPN actually is the publisher of the article, since they own Grantland.
Submitted to https://r.espn.go.com/members/contact/tvindex

Dear sir or Madam,

I am writing because I saw an advertisement for you on an article that I think you may not wish to be associated with. You may be aware of article on Grantland in which the journalist, Caleb Hannan, harasses his subject to the point of suicide. He is clearly aware of the harm he knows he causing her and uses it as part of his narrative arc. I’m sure that you do not wish to have your name associated with this kind of horrific bullying. Yet there is a link to you at the top of the page, implying endorsement. I would like to strongly encourage you to end your relationship with Grantland. I would also like to enquire if you have any policies which would apply if one of your own journalists submitted a similar story.

Thank you for your time,

Charles Hutchins

I’m not linking to the article. A ‘journalist’ decided to investigate the inventor of a new kind of putter. He speaks to her former employer who had used the threat of outing to get her to drop a discrimination lawsuit and then decided to out her anyway. He then called up everyone she knew to tell them personally that she was trans and ask them for comment. Having completely socially isolated her, he then calls her on the phone and tells her he’s going to out her in the press. She wrote him an email saying he was engaging in hate crime, which he included in the story. She took her own life, and he made sure to mention that the person who told him about this hated her and quote that person’s misgendering. He straight up caused somebody to die and then reported his role in it without a hint of remorse.
I’ve read some hateful shit. I’ve read bullying. I’ve read things that are intended to make the victim feel bad. But this, this kind of bloodless dispassionate, emotionally blank destruction of another human being is something I’ve never seen before. This is worse than anything I’ve ever encountered before. He kills someone and really is not at all bothered by it.
There’s a link to ESPN at the top of the socippath’s article and so I wrote to them. Their other adverts are automatically served by outbrain and are the same meaningless shit you see at the bottom of every article on earth. I clicked through on something that’s gone viral and the website is making money off of this. Because they have no qualms about bullying someone to death. Because it’s just a trans woman, so who cares.

Writing a bio

Charles Celeste Hutchins was born in 1976 and things went downhill from there. However, despite this, in 1989, he won his school’s raffle. He has not won a prize since.

He is one of the lucky few men to have completed an undergraduate degree at Mills College, where he studied composition with Maggi Payne. He graduated in 1998 and then, predictably, got caught up in the dot com boom. When that ended, he followed the path of most young people unsure of what to do next and went to grad school. He studied at Wesleyan University, working most closely on computer music with Ron Kuivila, and also studied improvisation with Anthony Braxton. They recorded an album together in 2005 which is still awaiting release.

After his 2005 graduation, he went to France to study at CCMIX, a musical center founded by Xenakis, who was no longer teaching there, having died some years previous. After that, he went to the Royal Conservatory of the Netherlands and took the year long Sonology course.

In 2007, he moved to England and began studying at the University of Birmingham, which awarded him a PhD in 2012. There, he studied with Scott Wilson. Also while a student, he was the instigator of BiLE, the Birmingham Laptop Ensemble – his colleagues claim he pressured them to sign up while drunk, but he has no memory of this. He also co-organised the Network Music Festival in 2012 and 2013, which is due to return in in 2014. It was while at Birmingham that he took the first name Charles, in honor of his recently deceased uncle Chuck Forge, and, of course, Charles Amirkhanian.

Since graduating, Charles has again followed a predictable path, working as an adjunct professor. He has taught at Anglia Ruskin University in Cambridge and now is teaching at the University of Kent.

During the nomadic wanderings of his last decade, he has played gigs in Europe and the US and also gotten some radio play in both places. He is relatively well-known to the users of SuperCollider both for his compositions and his contributions to the language’s libraries, although not so well known that people always get his name right when he comes up in discussion.

His current projects involve work with BiLE in making pieces that musically engage digital surveillance and writing computer-generated graphic notation in a piece for the Vocal Constructivists, a London-based choir.

Live blogging flossie: sound body gender

I’m reduced to taking notes with my phone, as my laptop battery life is not great.
i didn’t catch the name of the speaker, but she has a very impressive cv…
gender art started in ancient greece w sappho. She referenced her body and emotion. Women artists get recognised more in ethnography than art history.
Now a slide of Ada Lovelace’s program. Lovelace was the beginning of software. Sylvia Plath also represents a lack of support of women creatives. …..
Conceptual art and performance art of the 70s allowed a feminist critique. Women’s identity is opposed to a masculine tradition. New technologies allows new images and new thoughts. Ideals of masculinity and feminity are dominant in online communities. Most editors of wikipedia are men.
She is now talking aboout the anarchistic and artistic value of floss, talking about the ideology of collaborative working.
Now she is talking about the Art+FOSS book, which is really good. Fcforum.net is a useful resource for artists, tech and activism. Artists were prosecuted under anti-terrorism laws and fcforum helped them.
Free Culture has festivals like piksel in norway. They support a lot of hacker artists.
Composer Shelly Knotts has a controversial post about women in live coding on her website. Norah Lorway is also a live coder, who works collectively. She is part of the OpenLab underground London collective.
Many performers are activists. She seems to be assrting that live code is a path to utopian, collective futures.
Gender art paratice can queer technologies.

live blogging flossie: BCS Women

Talk by Louise Brown.
BCS is the British Computer Science professional body, representing members in the IT profession. A learned society with a royal charter and can charter people and offer qualifications and is a charity. It wishes to be the gold standard for diversity in the IT sector.
15% of the 70k members are women. There are more than 50 specialist groups, one of which is BCS Women (and another is the Open Source Specialist Group).
BCS Women is volunteer-driven group. They aim to support members and raise awareness of women in IT. trying to get more women into IT. They want to put up posters in schools around women in IT. They do Android Programming ‘family fun days’ – a one day workshop, aimed at families, that lets people try coding.
They run a Lovelace Colloquium for undergraduate women. And did Open Source taster days that they ran jointly with the Open source Group and Fossbox. They did AppInventor, intro to git and intro to python.
FLOSS-UK in the spring has a call for papers.
the BCS is also having an AGM in a few days with a foss event.
www.bcs.org/bcswomen
www.bcs.org/category/17484

live blogging flossie: a tv collaboration in barcellona

They use pure data both in software, but also with paper objects and string stuck to walls
Free software changes your relation with your computer and by extension your relationship with a lot of technologies in your daily life.
The collective uses linux. Free software freed them from the concept of ‘good’ and ‘bad’ uses. They found new uses. Their technical experience is considered less valid, but people call on them to discuss politics. This frees them to try to do whatever they want.
they made a ‘possible impossible machine.’ the first version had a terrible interface. it was made collectively by a workshop by all the participants. they had a pd patch to make all decisions. this was absurd. this is not the best way to handle negotiations.
some uses to technology have a tendency to erase the human touch.
they use old tech to resist planned obsolescence.
Gender construction: they don’t know how it works, but they know how to use it. Women there have worked to lose fear of opening the closed boxes. Open source has helped enable this.
she has talked a lot about their process around ‘errors’. failure is part of free software culture – to recognise bugs and not hide problems. there can also be a problem when people ‘celebrate’ the power of a mistake (ie the aesthetics of glitch) in that foss guys sometimes get upset about it. the speaker feels it’s a part of feminism to give less power to the ‘expert’ but to work with people who are experimenting, learning and making interesting material. Her political position is against the specialist.
minipimer.tv

live blogging flossie: screens in the wild

twitter: @wildscreens
Digital media embedded in environment. Mediated urban space. Most common uses of big screens is commercial.
How to do something different with screens and allow people access instead of letting advertisers dictate to us?
there are some big BBC screens in the centre of some communities. 23(?) in the UK? These are supposed to regenerate communities. How will this work? Nobody knows, but we want a big screen. They are high up and it’s hard to do interactive content.
the research challenge is how to integrate the screens into the environment in a way that the community has input.
How does the public engage with them? How can they be used to interact? How can we enable open access?
Active research and iterative design process.
they did community workshops.
they came up with something like a photo booth. easy to use. people do a pose and others in remote locations copy those poses to create an interaction.
Open access is very difficult, especially things that run a long time. The technology is also expensive, which makes it hard to get access.
www.screensinthewild.org

Live blogging flossie: Pulse Project- touching as listening

(Last year, Flossie was women-only and a bunch of men complained. This year, they bowed to pressure and decided to let anyone attend. I’m the only boy in the room.)
Talk by Michelle Lewis-King, an American who uses SuperCollider(!).
This is based on pulse-reading and some Chinese medicine principles. She has an acupuncture degree.
Occidental medicine is based on cutting apart dead bodies. Whereas Chinese medicine is more ‘alchemistic’, she says. Western medicine is from looking at dead bodies. Chinese medicine is based on feeling living bodies.
Pulses are abstractly linked to a type of music of the spheres.
She started drawing people’s pulses at different depths. This is sonic portraiture.
She found the SuperCollider community to be problematic to ask questions due to differences in ‘architecture’ differences. Some of the tutorials are not easy. She says the book is great because of the diversity of approaches. People at conferences have criticised her code, which is not a fun experience.
The community also provides a lot of support. The programme is free, community oriented and a useful tool.
She’s playing one of her compositions. It’s a pulsing very synthesised sound.
More info: journal.sonicstudies.org/vol04/nr01/a12 4th issue of the Journal of Sonic Studies
Twitter @vergevirtual

Vegan Apple Cake

  • 225g (1¾ US Cups) self-raising flour (or 220g (still 1¾ US Cups) plain white flour + 1 tsp baking powder)
  • ¼ tsp bicarbonate of soda
  • 1 tsp baking powder
  • A pinch of sea salt
  • Optional: A pinch of ground cardamom seeds, a grating of fresh ginger (or use ½ tsp ground), ½ tsp cinnamon, ½ tsp nutmeg
  • 450g (1 lbs) cooking or dessert apples
  • A little lemon juice
  • 100g (½ US Cup) sugar
  • 125 mL (½ US Cup) olive oil
  • 1 mooshed bananna
  • 50g (¼ US Cup) soft brown or demerara sugar (or caster sugar is fine)

The spices are optional and you can use more or less to your taste. Once you’ve gathered your ingredients:

  1. Sift flour, bicarb of soda, salt and spices (if using) into a mixing bowl. Mix thoroughly.
  2. Peel the apples. Cut into very small, think pieces. Toss the cut apples in a little lemon juice as you go, to keep them from browning.

  3. Mix in apples, sugar, oil and banana into the flour mix. Gently fold through until everything is thoroughly mixed. Turn into a greased cake tin.

  4. Level off the top of the batter. Sprinkle with sugar.

  5. Bake in a preheated moderately hot oven (200°C/Gas 6/375°F) for 30-40 mins. Test with skewer.

  6. Remove from oven. Allow to shrink slightly before turning out onto serving plate.

Variations

If you want a slightly heavier, richer cake, you can substitute 100g (½ US Cup) margarine + 1-2 Tbsp soy milk for the olive oil. Add margarine just after sifting the flour and spices together, cut it into the flour mixture and and rub into breadcrumb consistency. Then add the soy milk just after adding the apples, sugar etc. Add enough to wet the batter and hold it together.