Jersey Sore

I’ve lived in New Jersey now, off and on, for nearly twenty years, but I’m not a native. I was born in Michigan and have at various times lived in New York, Indiana, Rhode Island, Maryland, California, New Hampshire, and the British Virgin Islands. None of the places I’ve lived has been perfect. They all have their good and bad points. When it comes to New Jersey, though, nobody seems to acknowledge the good. From comedians to columnists to Internet forum posters the standard line is that New Jersey consists of a single strip of industrially polluted concrete running from New York to Philadelphia, studded with chemical plants, refineries, landfills, and tanning salons. Now, thanks to MTV’s “Jersey Shore,” everyone also thinks that the open space between the salvage yards and tattoo parlors is crammed with orange-tanned goombahs sporting oily hair and neck chains.

If that’s your view of New Jersey, then rejoice. Your ignorance quotient is about to be attenuated significantly. You’re about to learn that not only is New Jersey nothing at all like the popular stereotypes would have it, it is in fact one of the most beautiful places in America. From the mountainous Highlands of the northwest, to the fertile rolling hills of the midlands, and the vast undeveloped tracts of pinelands in the southeast, New Jersey combines a little slice of everything that is best about our continent. I won’t ask you to take this on faith. In order to make my point I’ve combed through thousands of pictures of the state that I have taken over the years, and selected fifty that I think show a New Jersey most of you don’t know exists. This is the New Jersey that I know, and I’d like you to know it too.

When you’re through enjoying the images, consider this: all that beauty, the pines, the highlands, the hunt country, the Delaware River, Delaware Bay, miles of shoreline, all of it, is within 1-2 hours of New York City and Philadelphia, and 3-4 hours from Baltimore and Washington, DC. In other words, we win. We have our share of problems, to be sure. Taxes are too high, and we have a lot of challenges in terms of how to maintain economic growth and rebuild infrastructure… but then so do the states most of you live in, and our Governor doesn’t have a secret second family. Yet. So the next time you see some Jersey-hater hating, point them toward this post so they can get some education. Better yet, come visit yourself. Then you’ll know what I’m talking about.

Creating Image Thumbs with TransformedBitmap and ScaleTransform

With WPF and the classes in the System.Windows.Media.Imaging namespace, creating thumbnails from source images has never been easier to do. The code fragment below illustrates how to create thumbnails from a source image using TransformedBitmap and ScaleTransform. You can use the same technique to apply other types of transforms to an image, such as rotations.

Let’s first define our method signature…

using System.Windows.Media;
using System.Windows.Media.Imaging;
void CreateThumbnail(string sourceImage, string outputImage, int width, int height)

The next thing to do is to get our source image into a BitmapSource…

BitmapSource imageSource = BitmapFrame.Create(new Uri(sourceImage));

The class that defines the transformation to be applied to the image is ScaleTransform. We need to create one of these and set the scaling factor to be applied to the width and height…

ScaleTransform st = new ScaleTransform();
st.ScaleX = (double)width / (double)imageSource.PixelWidth;
st.ScaleY = (double)height / (double)imageSource.PixelHeight;

With the transform defined, we need a TransformedBitmap to apply it to…

TransformedBitmap tb = new TransformedBitmap(imageSource, st);

The TransformedBitmap now contains the bitmap after the scaling transform has been applied. The only thing left to do now is write it to disk. In the process we’ll add some metadata just to show how that is done as well…

BitmapMetadata thumbMeta = new BitmapMetadata("jpg");
thumbMeta.Title = "thumbnail";
JpegBitmapEncoder encoder = new JpegBitmapEncoder();
encoder.QualityLevel = 100;
encoder.Frames.Add(BitmapFrame.Create(tb, null, thumbMeta, null));
using (FileStream stream = new FileStream(outputImage, FileMode.Create))
{
    encoder.Save(stream);
    stream.Close();
}

And that’s pretty much all there is to it. As I mentioned above you can use this exact same approach to apply any of the other transform classes in the System.Windows.Media namespace. These are all derived from System.Windows.Media.Transform, and in addition to ScaleTransform they include: RotateTransform, SkewTransform, TranslateTransform, and MatrixTransform.

SmoothGen 0.9

Recently I went hunting for an open source slideshow tool that would work with my WordPress installation. I found lots of alternatives, but most of them interacted with the WordPress database in one way or another, typically by requiring the slideshow to be defined by attaching pics from the media library to a post, and then annotating the post with some tag that would kick off the slideshow.

There’s nothing wrong with the built-in media library, as far as it goes, but it isn’t really suited for managing large numbers of images sorted into categories, i.e. 30 images for one slideshow, 20 for another, etc. There are some plugins that improve on it, but this was all more complicated than I wanted it to be. All I wanted was to be able to prepare a folder of images and have the slideshow drive off of that. Fortunately I discovered exactly what I needed in JonDesign’s SmoothGallery 2.0.

SmoothGallery is a MooTools-based slideshow driver that works off of an HTML document or fragment that describes all the images in the slideshow, as well as the metadata associated with each image (title, description, etc.). The nice thing about this is that it is search engine friendly, and self-contained. The downside is that you have to prepare the HTML document that describes the slideshow. I’m pretty lazy, and didn’t relish the idea of manually adding image elements for 50 slideshow images. So I wrote a tool to do it for me.

SmoothGen is a simple console program that takes as input a folder of images, and outputs a complete HTML document describing the slideshow. It supports all of the options available in SmoothGallery, as well as some additional features such as alternative thumbnail sizes, changing the height of the info pane, and importing title/description fields from image metadata. It was written to work with SmoothGallery 2.0, and requires the .Net framework version 4 to run. The source is included, so you should be able to rebuild it for earlier versions of the framework if you need to. If you have any questions that aren’t answered in the documentation, feel free to drop a comment here.

Download SmoothGen 0.9

Re-run TV?

I got a kick out of this. It was revealed this week that the share of downstream Internet traffic generated by Netflix customers’ streaming movies reached thirty percent in the last measuring period. Thirty percent. But as eye-opening as that figure is, it’s not what I got a kick out of. In some bit of reporting associated with that announcement I learned the following little gem: the pet nickname by which people in Hollywood sometimes sneer at Netflix is “Re-run TV.” I find this genuinely funny. Twenty-five or -six million people (including me) are streaming content from Netflix, comprising thirty percent of all downstream traffic, but Hollywood can still look down on them because they’re just “re-runs.”

In the world these guys grew up in, the one in which their business model was based on total control of content and delivery, there was for each piece of programming a “first run” during which the media biggies allowed people to watch it once, assuming they could be in front of the delivery device at the appointed time. Subsequent performances were “re-runs” for which the media corps were paid big bucks by smaller networks and independent broadcasters. Run, and re-run. And since everything on Netflix has been seen before, why hell it’s all just a bunch of re-runs. In their world, once, and in their dreams now, the viewing public flocks to them en-masse for the must-see content, and once that content has been seen they might agree to dribble it out bit by bit to other, clearly inferior outlets.

Meanwhile, on Planet Reality, I got to watch five seasons of Lost, all of Battlestar Galactica, Firefly, four seasons of Rescue Me, Weeds, Big Love, Torchwood, and dozens upon dozens of documentaries and movies, including most recently all the best, campiest Bond flicks from the sixties. Some of the movies I’ve seen before. Most of the television I haven’t. It’s all “first run” to me, and delivered to my computer, in my office, or on either of our two TVs, when I want to watch it. More importantly, the only way any of the networks can get anywhere near having twenty-six million people care what they are doing on a given night is to get two cute royal kids to marry each other. Hard to pull that off regularly.

Indie Fiction @ The 4th Realm

My friend Kris Kramer is running a website that highlights indie fiction over at The 4th Realm. The site was originally set up to feature serial shared-world stories that he and some friends are working on, but the group is now soliciting other works of fiction to appear on the site. My story “Authenticity” was just posted there over the last few days. Here’s an excerpt….

Marton gripped the armrests of his chair and stared at the pad on the desk. His face looked grainy and skewed on the screen, but it was his face. His face. He shifted, and the leather cushion squeaked under him. On the bookshelf behind Gruenwald a small digital clock blinked. The ventillation system came on and in the far corner of the room a potted plant shuddered as the air began to move. Marton looked up. “I don’t know who I’ll be,” he said.

“You,” Gruenwald said. “In every internal respect that matters: memories, thought patterns, reactions, emotions, hopes, dreams. Self-consciousness. All the things that make us who we are.”

“But the body…”

“Will be very strange at first. Exceedingly strange. But you will become used to it. People have body parts removed, and they become used to it.” Gruenwald picked his stylus up from the desk and held it in both hands, rolling it between thumbs and forefingers. He smiled. “If you could have a body part added,” he said, “something which is fortunately no longer legal, you would become used to that too. It is the same here. In a few months you will feel as if it has always been yours, and Marton, it is a younger and much better body.” He put the stylus back down. “It is worth every penny of one hundred million dollars.”

If you’re interested please stop by The 4th Realm to check out the rest of the story. If you do, be sure to leave a comment to let us know you stopped by. If you’re an aspiring writer, consider joining the site community. For more information on that shoot Kris an email at kriskramer@the4threalm.com.