Okay, so I use sprint, and their stupid method of emailing picture messages annoys me to no end. I otherwise like their service, and even if I didn't, we're married for the next two years anyhow :)
Anyway, so I noticed with my samsung A900, I was posting pictures to livejournal and noticing they looked small and grainy. For a 1280x960 image, that didn't look right. It turns out that the actual image livejournal is posting is based on the xml crud in the email, which actually generates a small version of the image suitable for mobile phones. Ugh.
<!-- lsPictureMail-Share-iETr4JPjm77BG8Bo7UHh-comment <?xml version="1.0" encoding="UTF-8"?> <shareMessage> <messageContents type="PICTURE"> <messageText>Hi</messageText> <mediaItems> <mediaItem id="1"> <title></title> <url>http://pictures.sprintpcs.com/getMMBOXMessageMedia?id=Xw1004H8sLv6S3x76lVPYmsnJP2O20g3zlhB%2Fx7njqW9MscUXIEXBQmk5gW%2FZUWGmojEaNnHPws%2F%0A5lpklQ8%2Bufjui%2BAXcLyJG3ClZw2m2Gi1qkXdBdb5KgoH8KyzBNpwHmgReddy4aqnGyBYMpsPyA%3D%3D%0A</url> <urlExpiration>2006-03-10T19:31:51Z</urlExpiration> </mediaItem> </mediaItems> </messageContents> </shareMessage> --> <!-- lsPictureMail-UserInfo-iETr4JPjm77BG8Bo7UHh-comment <?xml version="1.0" encoding="UTF-8"?> <UserInfo timestamp="2006-03-03T19:31:51.785+00:00" originating_from_address="USERNAMEREDACTED@pm.sprint.com"><credential name="MDN">248XXXXXXX</credential></UserInfo> -->
Anyway, there's some useful information, and the parser for this is at line 200 of livejournal/cgi-bin/ljemailgateway.pl.
Now, I'm a perl ninja and all, but I really don't want to hack this deep into the code having never laid my hands on it before, and offer up a patch that will one day break, or not work right, so I'm hoping that if I supply a method of grabbing the full media file, someone else can make the fix and push it in? :)
Anyway, the key is in the actual body of the email, in the middle of the HTML. Yes, I know, parsing HTML to get this is fugly. Just wait, because it gets worse.
Okay, so there's the line from the email that has the actual image string we want in it. Here's what you have to do:
Search the email for an image tag with the string "/mmps/RECIPIENT/" in the src.
Pull out the url:
In the real email, they're actually HTML entities too, so you have to use HTML::Entities::decode_entities() to make it work right. It's already loaded (and used in the current code) so no biggie.
What you have to end up doing is removing all arguments to that URL, except for inviteToken=blalbalbalblab and ext=.jpg
So it now looks like:
This has the upside of removing the stupid "frame" from around the picture too. ugh.
You now hold the raw media file, which in this example, is from my girlfriend's 640x480 phone, a picture of hello kitty.
The upside to this URL, is also, strangely enough, that unlike the tag in the XML, this image does not expire. You can fetch it at any time, even if the mailserver is lagging bad, and doesn't process the message for the default expiry of 7 days.
I'd be willing to pitch in what I can in terms of code to get this going, but from my description, it should be pretty self explanitory, and allow for much higher quality images to come from sprint phones.