crowley code!

Posts tagged “curvr”

2/5 Stop doing it yourself and use CPAN — curvr-0.2 (0)

api, c, curvr, dopplr, flickr, perl

Just like the career of the average software engineer, Curvr has now grown up just a bit and started reusing other people’s code.

Dopplr integration in curvrmail

Geotagging is awesome but a bit of a pain to automate with any kind of accuracy. I’m making a compromise here by automatically tagging things using my location according to Dopplr. I had this working with my original PHP curvrmail script but have since switched to using Flickr::Upload::Dopplr just to practice some Perl.

AutoManual image rotation

Since my N73 isn’t friendly enough to rotate pictures for me, I’ve added a way to specify rotation in the email you send to Curvr. Prefixing with “L ” or “l ” will rotate 90 degrees counterclockwise and prefixing with “R ” or “r ” will rotate 90 degrees clockwise. Note in both cases that it is a letter followed by a space followed by the normal title/tags syntax.

It is a bit awkward to think about in terms of left and right, since I could either be talking about the direction you rotated the camera or the direction the photo should be rotated (which itself could be rather ambiguous, so we’ll say that it is relative to the top). So here’s the official word: the rotate syntax wants to know which direction you rotated the camera to take the picture.

curvrconf for getting API tokens

Getting tokens for the Flickr and Dopplr API, while not something you need to do often, is quite a drag. Enter curvrconf, the copy-and-paste simple way to get your tokens out. All it needs is to be setup with the same API key as curvrmail and it’ll guide you through grabbing tokens. For the Flickr API, setup your key for web-based auth and give it a garbage URL to return to (I use http://localhost:81/).

As usual, the API key is up to you. I accidentally committed my keys/secrets/tokens to Subversion but have expired all of them so don’t even bother trying to steal my accounts.

Anti-blue C code

The main curvr program has for a long time introduced some strange blue artifacts into my photos. I figured this was due to some underflow or overflow issues with my color maps. I finally took the time to do some serious experimentation and it turns out that if I just favor a stronger red channel in these edge cases, the artifacts seem to go away. Strange and beautiful indeed. I can’t fully explain the phenomenon but believe it’s somehow related to my using the red channel as my indicator of color value (as many photographers do when converting to black & white).

So there it is, curvr-0.2.

Er, here it is: http://svn.rcrowley.org/svn/curvr/tags/curvr-0.2

12/30 (Post)fixing your (email) life (2)

c, curvr, exiv2, graphicsmagick, postfix, procmail

This post is about two things. Most proudly it is about me finally taking the time to setup all of the necessary gears and levers for my phone to post processed photos through to Flickr. Bonus-ly, it is about rolling what seems like your own email server from a few config files and Yahoo! Mail (or GMail, if your twisted brain is so inclined).

First, the fun stuff. I posted in November about curvr, my automated and assumption-filled command-line Photoshop. Refresher course here: http://rcrowley.org/2007/11/08/introducing-curvr/. The day after I wrote curvr I started to experience what can only be described as “crunch time” on Flickr Uploadr, so a quick shell script called curvall was born so I could at least use curvr after Bluetoothing photos from my phone.

Almost two months later and this is just silly. A different kind of crunch time, if you will. From a distance the solution isn’t nearly as ugly as the syntax of .procmailrc but I won’t be mean. I setup an MX record for my domain to send mail to the box in my apartment. From there, postfix rejects the riff-raff and passes the good stuff on to procmail which either works photos over with curvr or forwards to Yahoo! Mail for my consumption.

Postfix, there’s more to life than UNIX accounts

We need to teach postfix what email addresses to accept.

/etc/postfix/virtual:

r@rcrowley.org rcrowley@localhost
SPECIAL_CURVRMAIL_ADDRESS@rcrowley.org rcrowley@localhost

/etc/postfix/main.cf (available in SVN):

# See /usr/share/postfix/main.cf.dist for a commented, more complete version

# Debian specific:  Specifying a file name will cause the first
# line of that file to be used as the name.  The Debian default
# is /etc/mailname.
#myorigin = /etc/mailname

smtpd_banner = $myhostname ESMTP $mail_name (Ubuntu)
biff = no

# appending .domain is the MUA's job.
append_dot_mydomain = no

# Uncomment the next line to generate "delayed mail" warnings
#delay_warning_time = 4h

# TLS parameters
smtpd_tls_cert_file=/etc/ssl/certs/ssl-cert-snakeoil.pem
smtpd_tls_key_file=/etc/ssl/private/ssl-cert-snakeoil.key
smtpd_use_tls=yes
smtpd_tls_session_cache_database = btree:${queue_directory}/smtpd_scache
smtp_tls_session_cache_database = btree:${queue_directory}/smtp_scache

# See /usr/share/doc/postfix/TLS_README.gz in the postfix-doc package for
# information on enabling SSL in the smtp client.

myhostname = banzai
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
myorigin = /etc/mailname
mydestination = banzai, localhost.localdomain, localhost
relayhost =
mynetworks = 127.0.0.0/8
mailbox_size_limit = 0
recipient_delimiter = +
inet_interfaces = all

# Nasty homegrown config
virtual_alias_domains = rcrowley.org
virtual_alias_maps = hash:/etc/postfix/virtual
mailbox_command = /usr/bin/procmail

It really is important not to put the same domain in mydestination and virtual_alias_domains. Fecal matter and oscillating device and all that. Then run these commands:

$ sudo postmap /etc/postfix/virtual
$ sudo postfix reload

Procmail, your syntactic colon is full of shit

If photo, Flickr it. If not, throw it out into the cold.

~/.procmailrc (also available in SVN):

:0 bfW
* ^TO_<SECRET_CURVRMAIL_ADDRESS>@rcrowley.org
| /home/rcrowley/bin/curvrmail

:0 E :
! <normal_forwarding_destination>@yahoo.com

Now, Stephen R. van den Berg willing, email to your special address will be sent through curvr and onto Flickr (assuming you updated the curvrmail script with your secret Flickr email address) and all of your normal email will be forwarded somewhere else.

Yahoo-oooo!

I admit it, I like Yahoo! Mail. So I have my .procmailrc forwarding to Yahoo! Mail. Over at Yahoo! Mail I have a default mailbox setup as the-first-letter-of-my-first-name@rcrowley.org so that I can also send mail as my better email address.

Anyway, it’s all in SVN: http://svn.rcrowley.org/svn/curvr/

I’m interested to know how similar this all is to Aaron’s filtr workflow.

11/8 Introducing curvr (5)

c, curvr, exiv2, graphicsmagick

All inspirational credit, including the name, go to Aaron Straup Cope (filtr).

Curvr is a command-line tool that automates the most common operations I do in photoshop when I take pictures. I’m quite lazy and I hope that having this tool will make me take more pictures. This is the same line of reasoning that led me to an N73 and that is working out quite well.

I could just run Aaron’s filtr script, which does a sort of Lomo-y thing, but that’s not so much my style*. Instead, curvr perserves a little more reality and has a couple of key benefits. (* My style being slightly high-contrast but otherwise realistic.)

  1. Sets white- and black-points just like you can do in Photoshop’s Levels dialog.
  2. Tweaks the color curve to make mid-tones just a touch darker and force more contrast.

The tweak of the color curve has a couple of nice side effects. Since it doesn’t touch colors near the white- or black-points, things look pretty realistic. And for some reason, tweaking the mid-tones the way it does has the side effect of reducing haziness pretty effectively. Plus, skies pick up a really nice deep blue color.

My photography professor in college told us to use the red channel of the image to build black & white from color, rather than letting Photoshop convert it to greyscale. This advice carries through to the color mapping functions in curvr — when replacing colors, the red channel is used as the key into the color map. It works surprisingly well.

Now the how-to-get-it bit. On a Mac you’ll need MacPorts and a Terminal. On Linux you’ll probably be able to pick a lot of this up from your package manager (update the Makefile accordingly).

$ sudo port install libpng jpeg

Now you can unpack and install GraphicsMagick. The GraphicsMagick source can be obtained at ftp://ftp.graphicsmagick.org/pub/GraphicsMagick/. I use version 1.1.10.

./configure && make && sudo make install

Finally, curvr is just a simple make.

curvr 0.1 http://svn.rcrowley.org/svn/curvr/ http://github.com/rcrowley/curvr