Archive for March, 2007

Flickr: hacking comments and monitoring profile views

Posted in Odd Stuff on March 18th, 2007

I love Flickr. Seriously.

But one thing puzzles me: why do they allow off-site images in comments? It makes no sense to allow people to post comments on pictures with stupid animated gifs. It only makes sense to allow commenters to include other Flickr pictures as part of the discussion. Well, since they allow it, I decided to play with the concept a bit.

I have long used a PHP program to track views of my comments on other websites, most notably on PersonalMBA. My avatar is actually a link to a PHP program running on my site. The program (code below) records some information about the request in a log file, and then gives the JPG file over to the client. They never know that I’ve logged the fact that they requested my avatar. What have I done with this information? Pretty much nothing, except to give me an external view in to the popularity individual pages on the site.

So, I used this PHP program to leave comments on Flickr. But so as to not make things obvious, I have the PHP program send a 1×1 pixel clear GIF. The program then logs every time someone views another persons picture page on Flickr. Again, what have I done with this information? Umm, nothing, yet.

But it brings up another interesting possibility for the “off-site images in comments” thing that Flickr allows. If I can make it link to an off-site image, then I probably can change the image. If I wanted to do something devious, I could post a lot of “Great Shot” comments, including a reference to my off-site image. Initially the image would be a 1×1 clear gif so no one could know. Then, when I feel evil, I could change it to something, um, evil. Yes, my account would be banned. Yes, the comments would be deleted, but not before my “evil” image was viewed thousands of times. And then I could do it again with a new account. Why would I do this? Um, again, I’m not sure.

Profile monitoring

So after all that evil making, I’ve figured a more innocuous use for my PHP program–logging how many times people view my profile in Flickr. I find it odd that Flickr doesn’t tell me this by default–they tell me the number of times my images and sets are viewed. Why not my profile?

So, the concept is the same. I include an image in my profile thusly:

The code, listed below, logs the request and delivers the image. I now have a way to satisfy my ego for how many times people view my Flickr profile. Yippee.

Here is my PHP code. I adapted it from somewhere, but I don’t remember where. You will need to modify it to specify the log file and the image file.

< ?php
//Modify these two to suite your needs
$vfile = "flickr.gif";
$filename = 'logfile.log';

function readfile_chunked($filename,$retbytes=true)
{
$chunksize = 1*(1024*1024); // how many bytes per chunk
$buffer = '';
$cnt =0;
// $handle = fopen($filename, 'rb');
$handle = fopen($filename, 'rb');
if ($handle === false)
{
return false;
}
while (!feof($handle))
{
$buffer = fread($handle, $chunksize);
echo $buffer;
flush();
if ($retbytes)
{
$cnt += strlen($buffer);
}
}
$status = fclose($handle);
if ($retbytes && $status)
{
return $cnt; // return num. bytes delivered like readfile() does.
}
return $status;
}

header("Content-type: image/gif");
readfile_chunked($vfile,false);

$somecontent = date('m-d-y H:i:s '). $_SERVER['REMOTE_ADDR']." ". $_SERVER['HTTP_REFERER']. " " . $_SERVER['USER_AGENT']."\n";

// Let's make sure the file exists and is writable first.
if (is_writable($filename)) {

// In our example we're opening $filename in append mode.
// The file pointer is at the bottom of the file hence
// that's where $somecontent will go when we fwrite() it.
if (!$handle = fopen($filename, 'a')) {
echo "Cannot open file ($filename)";
exit;
}

// Write $somecontent to our opened file.
if (fwrite($handle, $somecontent) === FALSE) {
echo "Cannot write to file ($filename)";
exit;
}

echo "Success, wrote ($somecontent) to file ($filename)";

fclose($handle);

} else {
echo "The file $filename is not writable";
}
?>

Orton Imagery — My current obsession

Posted in Odd Stuff on March 4th, 2007

My latest obsession is with Orton Imagery, or the Orton effect, or Ortonized photos, whatever you want to call it. I found a great introduction to the technique here.

Most of the explanations of the technique cover Photoshop, or Adobe elements, neither of which I own. I went looking for GIMP specific explanations, and found a decent one.

Before I get too far, you really should see some of the excellent work in the Orton Flickr pool. In a nutshell, the Orton effect adds an incredible dreaminess to a photo, immediately elevating it from snapshot to artwork.

So, my point here is to write a click-by-click tutorial for doing this in The GIMP, because, although the one above it decent, it left a lot to be desired for my (previous) level of GIMP experience. This applies to version 2.2.11.

  1. Open your image in The GIMP. (OK, I hope you can figure that much out).
    gimp1
  2. On the Dialogs menu, choose Layers.
    gimp2
  3. Right click on the Background layer and choose duplicate.
  4. Right click on the Background Copy layer and choose duplicate. You should now have three layers: Background, Backgroupd Copy, and Background Copy #1.
    gimp3
  5. Set the Mode for Backgroup Copy to Screen. If you click the eye in front of Background Copy #1, you’ll see that your image has an over exposed look to it. Be sure to click on the spot where the eye was to make the top layer visible again.
    gimp4
  6. Right click on the Background Copy layer again, and choose Merge Down. You will now have just two layers: Background and Background Copy #1.
  7. Select Background Copy #1 in the layers dialog.
  8. On the image’s Filters menu, point to Blur, and choose Gaussian Blur…
  9. Set the Blur Radius for Horizontal and Vertical to somewhere in the 20-30 range. This is something you can play with to see how you like it, and will depend on the resolution of your picture. Also, set the Blur method to RLE (OK, I don’t know why. I can’t tell the difference between RLE and IIR. Just DO IT!).
    gimp5
  10. Back on the Layers dialog, set Background Copy #1 to Multiply mode, and then play with the opacity to see what you like. Then change the mode to Dodge, and play, then Burn, then back to Multiply, then Soft Light, then Multiply. Anyway, you get the idea. This is where your personal preference will come in. I set mine to Multiply with an 88.6% opacity.
    gimp6
  11. Save your image as a JPG to post it on-line, or as a GIMP xcf if you want to keep the layers separate and still have the opportunity to play with it.
    gimp7