Archive for August, 2011

Desktop Wallpaper Calendar: September 2011

Advertisement in Desktop Wallpaper Calendar: September 2011
 in Desktop Wallpaper Calendar: September 2011  in Desktop Wallpaper Calendar: September 2011  in Desktop Wallpaper Calendar: September 2011

We always try our best to challenge your artistic abilities and produce some interesting, beautiful and creative artwork. And as designers we usually turn to different sources of inspiration. As a matter of fact, we’ve discovered the best one — desktop wallpapers that are a little more distinctive than the usual crowd. This creativity mission has been going on for over two years now, and we are very thankful to all designers who have contributed and are still diligently contributing each month.

We continue to nourish you with a monthly spoon of inspiration. This post features 25 free desktop wallpapers created by artists across the globe for September 2011. Both versions with a calendar and without a calendar can be downloaded for free. It’s time to freshen up your wallpaper!

Please note that:

  • All images can be clicked on and lead to the preview of the wallpaper,
  • You can feature your work in our magazine by taking part in our Desktop Wallpaper Calendar series. We are regularly looking for creative designers and artists to be featured on Smashing Magazine. Are you one of them?

Flamingo

Designed by Vlad Gerasimov from Russia.

Flamingo 23 in Desktop Wallpaper Calendar: September 2011

Colorful Apple

"Green, unripe apple takes on juicy colors." Designed by Mypoint from Poland.

Colorful Apple 96 in Desktop Wallpaper Calendar: September 2011

Lighthouse

Designed by Mohd. Aaqib from India.

Lighthouse 90 in Desktop Wallpaper Calendar: September 2011

September Bliss

"A simple and tasteful wallpaper for this year’s first fall month.The right amount of color, a hint of cheerfullness and style that blurs that line between the illustration and the calendar, makes one blissfull wallpaper theme." Designed by Flashxml.net from United Kingdom.

September Bliss 76 in Desktop Wallpaper Calendar: September 2011

September Breeze…

Designed by Christina Balanou from Greece.

Breeze 99 in Desktop Wallpaper Calendar: September 2011

Thank You

"It’s an illustration I made to say “Thank you” to a friend. :)." Designed by Stanimira Petrova from Bulgaria.

Thank You Soft 12 in Desktop Wallpaper Calendar: September 2011

Things Are Looking Up

"I was shooting a wedding and was searching for perfect light. I convinced my bride and groom to keep climbing up to the top of the mountain we were on, as soon as we crested the summit the shy sun was waiting for us and the sky burst alive. It was perfect. The early fall sun was headed back south and the air had that slight crisp to it. Winter was coming but not here yet. The very moment the groom saw the landscape in front of him unfold, he quietly spoke to his new bride “things are looking up”. She giggled a laugh only a newlywed could. Keep your head up – things are looking up." Designed by Las Vegas Wedding Photographers from USA.

Thingslookingup 14 in Desktop Wallpaper Calendar: September 2011

City Of Antwerp

"I took this picture of the skyline of Antwerp on a sunny afternoon. The skyline looked a bit different today though, it was a obstructed by a big boat, you can still see the cathedral at the left though. I hope you like the wallpaper!" Designed by Yentl (design 311) from Belgium.

City Of Antwerp 90 in Desktop Wallpaper Calendar: September 2011

Got Ink?

"I guess we ran out of ink…" Designed by Almog Shemesh from Israel.

Got Ink 71 in Desktop Wallpaper Calendar: September 2011

Geometric

Designed by Tomek Walecki from Poland.

Geometric 23 in Desktop Wallpaper Calendar: September 2011

Big Dinner

"Autumn is the right time for stock up in vitamins." Designed by Cheloveche.ru from Russia.

Big Dinner 1 in Desktop Wallpaper Calendar: September 2011

Pyre In The Sky

"With September comes the distinctive feeling that Summer is over and Winter is fast approaching. But in the East Coast, Fall translates into a glorious palette of brilliant warm tones burnished oranges, yellows, reds as the leaves change color. It is as if the lazy, hazy remanents of Summer are being vanquished by a pyre in the sky." Designed by Jen Cheng from Canada.

Pyre In The Sky 22 in Desktop Wallpaper Calendar: September 2011

La Mesa

"This is the leg of a table in the Queretaro Regional Museum (Mexico). Just love it!" Designed by Alicia Ramirez from Canada/Mexico.

La Mesa 50 in Desktop Wallpaper Calendar: September 2011

Feel Free!

Designed by Dana Gerigk from Germany.

Feel Free 71 in Desktop Wallpaper Calendar: September 2011

Dance

"These images were taken of Nicole Marquez in one of her first studio dance sessions since falling three years ago from her sixth story apartment window. She was internally decapitated, broke her lower back, pelvis and all the ribs on one side. Doctors thought she wouldn’t make it through the night for she lay on an 8 inch broken bottle for over 8 hours before being discovered. She is steadily recovering and proved the doctors wrong in that she not only walked again but she dances and teaches others. She’s a motivational speaker and a living miracle. Here are more links to her story. and this is her website." Designed by Talamieka Brice.

Nicolewallpaper 52 in Desktop Wallpaper Calendar: September 2011

School Fun

"Going to school should be fun. I illustrated a fun little character who loves school and motivates kids to perceive it as educational and fun." Designed by Hayat Sheikh from Lebanon.

School Fun 2 in Desktop Wallpaper Calendar: September 2011

Red Beetle

Designed by Oxana Kostromina from Russia/Germany.

Red Beetle 46 in Desktop Wallpaper Calendar: September 2011

Peacefall Critters

"Cute and cuddly fall wallpaper that’s just sure to keep away that autumn gloom. This was a welcome mood changer for our designers to make and we hope it will be for you aswell." Designed by Flashxml.net from United Kingdom.

Peacefall Critters 12 in Desktop Wallpaper Calendar: September 2011

Jonathan Livingston Seagull

"The story of Jonathan Livingston Seagull, a seagull who is bored with the daily squabbles over food." Designed by Monika Holeckova from Slovakia.

Jonathan Livingston Seagull 94 in Desktop Wallpaper Calendar: September 2011

Yellow Submarine

"The dog is exploring in a yellow submarine, a yellow submarine." Designed by Rachel Cronover from United States of America.

Yellow Submarine 30 in Desktop Wallpaper Calendar: September 2011

Salamander

Designed by Laurebc from France.

Salamander 49 in Desktop Wallpaper Calendar: September 2011

Moods & Moments

"In our routine life we are always behaving with our moods. some moods and moments are not easy to forget.it is always leaves impressions in our mind. Here is the idea how looks the collage of moods & moments." Designed by Hiren Rawal from India.

Moods N Moments 72 in Desktop Wallpaper Calendar: September 2011

Love And Friendship

"In my country, September is the month of love and friendship, a month full of presents and lots of fellowship, flowers gifts and kisses invade every corner of my beautiful country Colombia." Designed by Jose Luis Rodriguez Martinez (pu+) from Colombia.

Love Friends 7 in Desktop Wallpaper Calendar: September 2011

Join In Next Month!

Please note that we respect and carefully consider the ideas and motivation behind each and every artist’s work. This is why we give all artists the full freedom to explore their creativity and express emotions and experience throughout their works. This is also why the themes of the wallpapers weren’t anyhow influenced by us, but rather designed from scratch by the artists themselves.

A big thank you to all designers for their participation. Join in next month!

What’s Your Favourite?

What’s your favorite theme or wallpaper for this month? Please let us know in the comment section below!

(il) (vf)


© Smashing Editorial for Smashing Magazine, 2011.


Photography in Action : Performing Arts


  

With so much of photography being focused on still life imagery, and using said imagery to evoke emotion, we wanted to shift gears. Turning our focus instead on some of the awesome captures of photography in action. Those perfect pics that freeze a moment, stealing it from its momentum and forward drive, while still carrying so much of that action and energy with it. Welcome to Photography in Action: Performing Arts.

Below is a showcase of some very inspiring photographs by some talented artists who trained their eye on the performing arts to steal moments from. So much life bursting forth from each one that it is hard to not feel their push as you browse through them. Take a look and get inspired.

The Arts in Action

Burn the sky by bast-86

red lights by idiot-drug-hive

In Motion 20’58 by astrsk

Colour of Culture by pace067

Untitled by Thoum

Tango by sedats

7685 by celil

c h o r e f t r i a by tavernofmedusa

UID 445 by eelmikashigaru

Fringed by king-dither

Playing With Fire by dmack

Ciriaco by Padx

Curtidores de Hongos by Mauricioluis

Tippy-Toes by Massayume15

UID 927 by eelmikashigaru

one hundred and fifty four by potato-juice

Window Lit Stretch by HowNowVihao

dancing angel 1 by guitar-hero90

mirror dance by nowaryesblack

Two Dancers by HowNowVihao

Concepts 20’21 by astrsk

Circus Klezmer by PtiteCocci

Nutcracers Ballet Show 12 by solak11

Angels don’t play harps by Obsidian-Fox

To Jocelyn by bittersweetvenom

Event Horizon by Doomsday-Dawn

Ladder by HowNowVihao

Bulresque by lemures-ex

Walking in the air by hipster7

carnival 03 by enomis

Belly Dancer 3 by Dislexik2501

Bruise Violet Fan Dance by photoswithattitude

Misty Venice by p11oto

How Many by the-chipmeister

paramore by the-feel-good-drag

h a r e m by nowaryesblack

Passe la Balle IX by Thoum

728 by lenagn

Dobro by strugg13

Levi Ben Baruch by guyprives

okissi 3 by khurafati

Playing Hard by TimberClipse

(rb)


Breaking Down Silos, Part 1: The Consequences Of Working In Isolation

Advertisement in Breaking Down Silos, Part 1: The Consequences Of Working In Isolation
 in Breaking Down Silos, Part 1: The Consequences Of Working In Isolation  in Breaking Down Silos, Part 1: The Consequences Of Working In Isolation  in Breaking Down Silos, Part 1: The Consequences Of Working In Isolation

No man is an island entire of itself; every man is a piece of the continent, a part of the main…

– John Donne

If you’ve ever worked at a company of any size, you’ve experienced it. Isolation. That feeling of being utterly alone in what you do.

Some people love it: the determination that comes from being a lone ranger, boldly going where no one has gone before. Others hate it: the despair that comes from slaving over a design only to see it disappear down a black hole of development, whereupon it emerges onto a website months later, unrecognizable from the pixels you put on the page with such painful precision.

Island in Breaking Down Silos, Part 1: The Consequences Of Working In Isolation
Image credit: Ibrahim Iujaz

These are the perils of working in siloed environments, and it’s where many of us find ourselves today. We’re either terribly alone or terribly frustrated, depending on the particular variety of silo we find ourselves in. In this two-part series, I’ll explore the consequences of working in isolated environments, and how we can solve this problem by encouraging more collaborative cultures.

What Exactly Are We Talking About Here?

Silos in work environments usually come in two flavors:

  1. Lonely silos
    Lonely silos are made up of workers with no real connection to the outside world. This often happens at start-ups where the focus is more on getting something out the door than on doing it right. I mean, who has time for proper UX design when “we’re building [technology x] because [company y] hasn’t built it and [people z] need it?� (as Kyle Neath recently put it).
  2. Functional silos
    Functional silos feature workers who may be part of fantastic design teams. They have great whiteboard sessions, help each other out, enjoy their pizza Fridays… And yet, they have no real seat at the table when it comes to business strategy. Design happens painfully slow because it has to be signed off by 10 different people. And even then, there’s no guarantee that anything will be implemented the way the designers envisioned it.

Working in lonely silos and functional silos have two main consequences, both devastating to software development:

  1. No process
    This usually happens in lonely silos. It’s everyone for themselves. The company subscribes to the “release early, release often� approach, and so you won’t get bogged down with a formal development process, guidelines for functional specs or any of the stuff that big lame corporations busy themselves with.
  2. Too much process
    This usually occurs when functional silos get out of control. Organizations resort to putting hierarchies and processes in place to stop the “cowboy coding� madness. The science:art ratio in design shifts way too much to one side or the other. Functional specifications move into Microsoft Word templates that are 20 pages long before a single word of content is written. And sure enough, the cowboy madness stops. But it gets replaced with a different kind of madness: stagnation.

The Consequences Of Not Following A Design Or Development Process

When you work in an environment where silos result in no clear design or development process, the following often happens.

1. MVP Madness

We all know the concept of “Minimum Viable Product,� but revisiting Eric Reis’ definition would be useful:

The minimum viable product is that product which has just those features (and no more) that allow you to ship a product that resonates with early adopters; some of whom will pay you money or give you feedback.

Problem is, that last section of the definition often gets ignored. You know, the part about people paying you money. So this MVP idea can be taken too far, and a product can be released before there is a minimum viable understanding of what the thing is supposed to do (or who it’s supposed to be useful for). You could argue that the Color app is an example of this MVP madness (“It’s a photo app!� “No, it’s a data-mining app!� “Actually, it’s a local group-messaging search/recommendations app!�)

Perhaps the best example of this culture is the Lifepath sign-up page, which Dustin Curtis recently put up in what I’d like to believe is a deliberate and very effective attempt at MVP irony:

Lifepath1 in Breaking Down Silos, Part 1: The Consequences Of Working In Isolation
Lifepath sign-up page

A lot of this problem would go away if we evolve MVP thinking into what Andrew Chen calls “Minimum Desirable Product�:

Minimum Desirable Product is the simplest experience necessary to prove out a high-value, satisfying product experience for users.

I think that definition would send a lot of MVPs back to the drawing board, and rightfully so.

2. No Significant Design Focus

The second consequence of a lack of process, particularly in start-ups, is that design is often the last thing on people’s minds. I recently heard an interview with a start-up founder who gave the following overview of their staff: “We have 13 employees: 9 software developers, 2 sales people, 1 operations manager and a social media conversationalist.�

The company hired a social media conversationalist before it hired a designer. In this type of no-process world, ideas go from vision to code (and users) in one easy step, bypassing the principles of user-centered design completely. As Erika Hall puts it:

The floor of Silicon Valley is littered with the crumbling husks of great ideas — useful products and services that died in the shell before they hatched out of their impenetrable engineering-specified interfaces.

3. Endless Cycles

A third consequence of no-process development is that you never really know when you’re done. Not to make this about methodology, but this is one area where the “definition of done� concept in Scrum is extremely useful. If you don’t know when you’re ready to push something live, then the problems of MVP madness and lack of design are exacerbated.

Google Wave is a case in point. Listen to Douwe Osinga as he gives two good examples of MVPs done right before moving on to the problem with Google Wave:

Thinking big sounds great, but most big ideas start small and go from there. Google itself started from the notion that it would be interesting to look at back links for pages. Twitter started out as hardly more than a group SMS product that also works online. Facebook explicitly restricted themselves at first to one university.

Wave is a case in point. Wave started with some fairly easy to understand ideas about online collaboration and communication. But in order to make it more general and universal, more ideas were added until the entire thing could only be explained in a 90 minute mind blowing demo that left people speechless but a little later wondering what the hell this was for.

The Consequences Of Having Too Much Design/Development Process

So that’s what can happen in a no-process environment. But what happens at the other end of the continuum, where process is king of the world?

1. Org-Structure Design

When you can sketch out an organization’s structure by looking at its home page, chances are it’s hopelessly lost in functional silos. I experienced this first-hand while working at eBay. I would sometimes run into the product manager for the home page in the morning, and he’d have no idea why his page looked the way it did on that particular day. Each day was an adventure to see what had changed on the page that he “owned.�

Don’t believe me? Below is an example of the eBay home page from about a year ago, with the teams responsible for each section of the page overlaid (they’ve since gone through a redesign that fixed this issue):

Ebay-silo in Breaking Down Silos, Part 1: The Consequences Of Working In Isolation

This is unfortunately one of the side effects of functional silos. You run the risk of losing any sense of holistic design direction on the website.

2. Design Monkeys

Another consequence of an over-reliance on process is that designers could become nothing more than monkeys, cranking out efficient, perfectly grid-aligned but completely uninspired designs on an assembly line. Wondering whether this is you? Here are some instructions you might recognize as a design monkey:

Pop-1024x88 in Breaking Down Silos, Part 1: The Consequences Of Working In Isolation

Web2-0 in Breaking Down Silos, Part 1: The Consequences Of Working In Isolation

Comicsans F in Breaking Down Silos, Part 1: The Consequences Of Working In Isolation

Don’t get me wrong: I believe in style guides, and I believe in design constraints. But when an organization becomes overly reliant on design rules, creativity is often the first thing out the door. Yes, design is much more than art (we’ll come back to this later), but it’s certainly not pure science either. Without the right injection of art and creativity, science gets boring and forgotten pretty quickly.

3. Tired Developers

Once process takes over an organization, the acronyms start. And arguably, the most feared of them all is PRD: the product requirements document. This usually takes the form of a Word template, with a two-page table of contents. It includes a solution to every single eventuality the software might ever encounter. It sucks the soul out of product managers and the life out of developers.

To use another example from eBay, we once had a 23-page PRD to make some changes to our SiteCatalyst JavaScript implementation. And then the project didn’t happen. I shudder to think about the hours and hours of lost productivity that went into creating this document that never got used. People could have created things during that time. Instead, they sat in Microsoft Word.

The result? Tired developers. Developers who don’t want to code anymore because coding becomes 70% deciphering Word documents, 20% going back and forth on things that aren’t clear, and 10% actually coding.

How do you know that your developers are tired? Charles Miller’s explanation of what it means when a developer tells you that something is “non-trivial� sums it up pretty well:

It means impossible. Since no engineer is going to admit something is impossible, they use this word instead. When an engineer says something is “non-trivial,� it’s the equivalent of an airline pilot calmly telling you that you might encounter “just a bit of turbulence� as he flies you into a cat 5 hurricane.

Tired developers use the word “non-trivial,� or some variation thereof, a lot more than energized developers.

4. Distrust Between Teams

When people don’t live and breathe each other’s workflows, understanding the decisions they make is hard. And if you don’t understand the reason for someone’s decisions, distrust can creep in.

Functional silos that rely on too much process serve as fertile ground for distrust in relationships. A reliance on process can instill a false sense of security and the mistaken assumption that conversation and understanding are less important than proper documentation. This is particularly true in the complicated relationship between designers and developers. As Don Norman recently put it:

Designers evoke great delight in their work. Engineers provide utilitarian value. My original training was that of an engineer and I, too, produce practical, usable things. The problem is that the very practical, functional things I produce are also boring and ugly. Good designers would never allow boring and ugly to describe their work: they strive to produce delight. But sometimes that delightful result is not very practical, difficult to use and not completely functional. Practical versus delightful: Which do you prefer?

So, when designers and developers are not in the same room from the moment a project kicks off, or when design becomes prescriptive before thorough discussion has taken place and everyone has sweated the details together, the stage is set for the two worlds to collide. Breaking down these silos is the only way to design solutions that are practical and delightful.

5. Design by Committee

Not everyone can code, so they don’t go to developers telling them that their HTML needs to be more semantic. But everyone thinks they’re a designer, or at least has a gut feeling about design. They like certain colors or certain styles, and some people just really hate yellow. Because everyone has an emotional response to design and believes “it’s just like art,� they think they know enough about design to turn those personal preferences into feedback.

One of the first things we need to do to solve this problem is to teach people how to give better design feedback. Mike Monteiro gets to the crux of the issue in “Giving Better Design Feedback�:

First rule of design feedback: what you’re looking at is not art. It’s not even close. It’s a business tool in the making and should be looked at objectively like any other business tool you work with. The right question is not, “Do I like it?� but “Does this meet our goals?� If it’s blue, don’t ask yourself whether you like blue. Ask yourself if blue is going to help you sell sprockets. Better yet: ask your design team. You just wrote your first feedback question.

And how do we respond practically to the problems of design by committee? Smashing Magazine’s own article sums it up best:

The sensible answer is to listen, absorb, discuss, be able to defend any design decision with clarity and reason, know when to pick your battles and know when to let go.

Here are four principles I use in my day-to-day work to make that statement a reality:

  1. Respond to every piece of feedback.
    This is tiring, but essential. Regardless of how helpful it is, if someone took the time to give you feedback on a design, you need to respond to it.
  2. Note what feedback is being incorporated.
    Be open to good feedback. Don’t let pride get in the way of a design improvement. And let the person know what feedback is being incorporated.
  3. Explain why feedback is not being taken.
    If a particular piece of feedback is not being implemented, don’t just ignore it. Let the person know that you’ve thought about it, and explain the reason for not incorporating that feedback. They will be less likely to get upset at you if you explain clearly why you’re taking the direction you’re taking. And if you’re not sure how to defend the decision…
  4. Use the user experience validation stack.
    Read the post “Winning a User Experience Debate� for more detail. But in short, first try to defend a decision based on user evidence — actual user testing on the product. If that’s not available, go to Google and find user research that backs up the decision. In the absence of that, go back to design theory to explain your direction.

Summary, And Where We Go From Here

Ending an article on such a doom-and-gloom note feels a bit wrong. But maybe pausing here would be good so that we can all reflect on the issues that siloed development creates in our own organizations. As UX people, we’re taught to understand the problem first before trying to solve it, right? So, let’s do that. Did I miss any consequences? Anything you’d like to add or challenge about the consequences I’ve highlighted in this article?

In part 2, I’ll explain my own journey with siloed development and go over some of the guidelines we’ve implemented to break down these silos and build collaborative teams that help eliminate the vast majority of the issues outlined in this post.

(al)


© Rian van der Merwe for Smashing Magazine, 2011.


Optimize Images With HTML5 Canvas

Advertisement in Optimize Images With HTML5 Canvas
 in Optimize Images With HTML5 Canvas  in Optimize Images With HTML5 Canvas  in Optimize Images With HTML5 Canvas

Images have always been the heaviest component of websites. Even if high-speed Internet access gets cheaper and more widely available, websites will get heavier more quickly. If you really care about your visitors, then spend some time deciding between good-quality images that are bigger in size and poorer-quality images that download more quickly. And keep in mind that modern Web browsers have enough power to enhance images right on the user’s computer. In this article, I’ll demonstrate one possible solution.

Let’s refer to an image that I came across recently in my job. As you can see, this image is of stage curtains and has some (intentional) light noise:

Example in Optimize Images With HTML5 Canvas

Optimizing an image like this would be a real pain because it contains a lot of red (which causes more artifacts in JPEG) and noise (which creates awful artifacts in JPEG and is bad for PNG packing). The best optimization I could get for this image was 330 KB JPEG, which is quite much for a single image. So, I decided to do some experiments with image enhancement right in the user’s browser.

If you look closely at this image, you’ll see that it consists of two layers: the noise and the stage curtains. If we remove the noise, then the image shrinks to 70 KB in JPEG, which is really nice. Thus, our goal becomes to pass a noiseless image to the user and then add noise to the image right in the Web browser. This will greatly reduce the downloading time and make the Web page perform better.

In Photoshop, generating monochromatic noise is very easy: just go to FilterNoiseAdd Noise. But in the original image, the noise actually darkens some pixels (i.e. there are no white pixels). This brings a new challenge: to apply a noise layer with the “Multiply� blending mode on the stage image.

HTML5 Canvas

All modern Web browsers support the canvas element. While early canvas implementations offered only a drawing API, modern implementations allow authors to analyze and manipulate every image pixel. This can be done with the ImageData interface, which represents an image data’s width, height and array of pixels.

The canvas pixel array is a plain array containing each pixels’s RGBa data. Here is what that data array looks like:

pixelData = [pixel1_red, pixel1_green,
pixel1_blue, pixel1_alpha, pixel2_red,
pixel2_green, pixel2_blue, pixel2_alpha, …];

Thus, an image data array contains total_pixels×4 elements. For example, a 200×100 image would contain 200×100×4 = 80,000 elements in this array.

To analyze and manipulate individual canvas pixels, we have to get image data from it, then modify the pixel array and then put data back into the canvas:

// Coordinates of image pixel that we will modify
var x = 10, y = 20;

// Create a new canvas
var canvas = document.createElement('canvas');
canvas.width = canvas.height = 100;
document.body.appendChild(canvas);

// Get drawing context
var ctx = canvas.getContext('2d');

// Get image data
var imageData = ctx.getImageData(0, 0, canvas.width, canvas.height);

// Calculate offset for pixel
var offset = (x - 1 + (y - 1) * canvas.width) * 4;

// Set pixel color to opaque orange
imageData.data[offset]     = 255; // red channel
imageData.data[offset + 1] = 127; // green channel
imageData.data[offset + 2] = 0;   // blue channel
imageData.data[offset + 3] = 255; // alpha channel

// Put image data back into canvas
ctx.putImageData(imageData, 0, 0);

Generating Noise

Once we know how to manipulate individual canvas pixels, we can easily create noise layer. A simple function that generates monochromatic noise might look like this:

function addNoise(canvas) {
   var ctx = canvas.getContext('2d');

   // Get canvas pixels
   var imageData = ctx.getImageData(0, 0, canvas.width, canvas.height);
   var pixels = imageData.data;

   for (var i = 0, il = pixels.length; i < il; i += 4) {
var color = Math.round(Math.random() * 255);

      // Because the noise is monochromatic, we should put the same value in the R, G and B channels
      pixels[i] = pixels[i + 1] = pixels[i + 2] = color;

      // Make sure pixels are opaque
      pixels[i + 3] = 255;
   }

   // Put pixels back into canvas
   ctx.putImageData(imageData, 0, 0);
}

// Set up canvas
var canvas = document.createElement('canvas');
canvas.width = canvas.height = 200;
document.body.appendChild(canvas);

addNoise(canvas);

The result could look like this:

Noise in Optimize Images With HTML5 Canvas

Pretty good for starters. But we can’t just create a noise layer and place it above the scene image. Rather, we should blend it in “Multiply� mode.

Blend Modes

Anyone who has worked with Adobe Photoshop or any other advanced image editor knows what layer blend modes are:

Blending-modes in Optimize Images With HTML5 Canvas

Some folks regard image blend modes as some sort of rocket science, but in most cases the algorithms behind them are pretty simple. For example, here’s what the Multiply blending algorithm looks like:

(colorA * colorB) / 255

That is, we have to multiply two colors (each channel’s value) and divide it by 255.

Let’s modify out code snippet: load the image, generate the noise and apply it using the “Multiply� blend mode:

// Load image. Waiting for onload event is important
var img = new Image;
img.onload = function() {
addNoise(img);
};
img.src = "stage-bg.jpg";

function addNoise(img) {
   var canvas = document.createElement('canvas');
   canvas.width = img.width;
   canvas.height = img.height;

   var ctx = canvas.getContext('2d');

   // Draw image on canvas to get its pixel data
   ctx.drawImage(img, 0, 0);

   // Get image pixels
   var imageData = ctx.getImageData(0, 0, canvas.width, canvas.height);
   var pixels = imageData.data;

   for (var i = 0, il = pixels.length; i < il; i += 4) {
      // generate "noise" pixel
      var color = Math.random() * 255;

      // Apply noise pixel with Multiply blending mode for each color channel
      pixels[i] =     pixels[i] * color / 255;
      pixels[i + 1] = pixels[i + 1] * color / 255;
      pixels[i + 2] = pixels[i + 2] * color / 255;
   }

   ctx.putImageData(imageData, 0, 0);
   document.body.appendChild(canvas);
}

The result will look like this:

Stage-noise in Optimize Images With HTML5 Canvas

Looks nice, but the noise is very rough. We have to apply transparency to it.

Alpha Compositing

The process of combining two colors with transparency is called “Alpha compositing.� In the simplest case of compositing, the algorithm would look like this:

colorA * alpha + colorB * (1 - alpha)

Here, alpha is the composition coefficient (transparency) from 0 to 1. Choosing which color will be the background (colorB) and which will be the overlay (colorA) is important. In this case, the background will be the curtains image, and the noise will be the overlay.

Let’s add one more argument for the addNoise() function, which will control the alpha blending and modify the main function to respect transparency while blending images:

var img = new Image;
   img.onload = function() {
   addNoise(img, 0.2); // pass 'alpha' argument
};
img.src = "stage-bg.jpg";

function addNoise(img, alpha) { // new 'alpha' argument
   var canvas = document.createElement('canvas');
   canvas.width = img.width;
   canvas.height = img.height;

   var ctx = canvas.getContext('2d');
   ctx.drawImage(img, 0, 0);

   var imageData = ctx.getImageData(0, 0, canvas.width, canvas.height);
   var pixels = imageData.data, r, g, b;

   for (var i = 0, il = pixels.length; i < il; i += 4) {
      // generate "noise" pixel
      var color = Math.random() * 255;

      // Calculate the target color in Multiply blending mode without alpha composition
      r = pixels[i] * color / 255;
      g = pixels[i + 1] * color / 255;
      b = pixels[i + 2] * color / 255;

      // alpha compositing
      pixels[i] =     r * alpha + pixels[i] * (1 - alpha);
      pixels[i + 1] = g * alpha + pixels[i + 1] * (1 - alpha);
      pixels[i + 2] = b * alpha + pixels[i + 2] * (1 - alpha);
   }

   ctx.putImageData(imageData, 0, 0);
   document.body.appendChild(canvas);
}

The result is exactly what we want: a noise layer applied to the background image in Multiply blending mode, with a transparency of 20%:

Stage-noise-alpha in Optimize Images With HTML5 Canvas

Optimization

While the resulting image looks perfect, the performance of this script is pretty poor. On my computer, it takes about 300 milliseconds (ms). On the average user’s computer, it could take even longer. So, we have to optimize this script. Half of the code uses browser API calls such as for creating the canvas, getting the image data and sending it back, so we can’t do much with that. The other half is the main loop for applying noise to the stage image, and it can be perfectly optimized.

Our test image size is 1293×897, which leads to 1,159,821 loop iterations. A pretty big number, so even small modifications could lead to significant performance boosts.

For example, in this cycle we calculated 1 - alpha three times, but this is a static value. We should define a new variable outside of the for loop:

var alpha1 = 1 - alpha;

And then we would replace all occurrences of 1 - alpha with alpha1.

Next, for the noise pixel generation, we use the Math.random() * 255 formula. But a few lines later, we divide this value by 255, so r = pixels[i] * color / 255. Thus, we have no need to multiply and divide; we just use a random value. Here’s what the main loop looks like after these tweaks:

var alpha1 = 1 - alpha;
for (var i = 0, il = pixels.length; i < il; i += 4) {
   // generate "noise" pixel
   var color = Math.random();

   // Calculate the target color in Multiply blending mode without alpha composition
   r = pixels[i] * color;
   g = pixels[i + 1] * color;
   b = pixels[i + 2] * color;

   // Alpha compositing
   pixels[i] =     r * alpha + pixels[i] * alpha1;
   pixels[i + 1] = g * alpha + pixels[i + 1] * alpha1;
   pixels[i + 2] = b * alpha + pixels[i + 2] * alpha1;
}

After these little optimizations, the addNoise() function runs at about 240 ms (a 20% boost).

Remember that we have more than a million iterations, so every little bit counts. In the main loop, we’re accessing the pixels array twice: once for blending and once for alpha compositing. But array access is too resource-intensive, so we need to use an intermediate variable to store the original pixel value (i.e. we access the array once per iteration), like so:

var alpha1 = 1 - alpha;
var origR, origG, origB;

for (var i = 0, il = pixels.length; i < il; i += 4) {
   // generate "noise" pixel
   var color = Math.random();

   origR = pixels[i]
   origG = pixels[i + 1];
   origB = pixels[i + 2];

   // Calculate the target color in Multiply blending mode without alpha composition
   r = origR * color;
   g = origG * color;
   b = origG * color;

   // Alpha compositing
   pixels[i] =     r * alpha + origR * alpha1;
   pixels[i + 1] = g * alpha + origG * alpha1;
   pixels[i + 2] = b * alpha + origB * alpha1;
}

This reduces the execution of this function down to 200 ms.

Extreme Optimization

An attentive user would notice that the stage curtains are red. In other words, the image data is defined in the red channel only. The green and blue ones are empty, so there’s no need for them in the calculations:

for (var i = 0, il = pixels.length; i < il; i += 4) {
   // generate "noise" pixel
   var color = Math.random();

   origR = pixels[i]

   // Calculate the target color in Multiply blending mode without alpha composition
   r = origR * color;

   // Alpha compositing
   pixels[i] = r * alpha + origR * alpha1;
}

With some high-school algebra, I came up with this formula:

for (var i = 0, il = pixels.length; i < il; i += 4) {
   pixels[i] = pixels[i] * (Math.random() * alpha + alpha1);
}

And the overall execution of the function is reduced to 100 ms, one-third of the original 300 ms, which is pretty awesome.

The for loop contains just one simple calculation, and you might think that we can do nothing more. Actually, we can.

During the execution of the loop, we calculate the random pixel value and apply it to original one. But we don’t need to compute this random pixel on each iteration (remember, we have more than a million of them!). Rather, we can pre-calculate a limited set of random values and then apply them to original pixels. This will work because the generated value is… well, random. There’s no repeating patterns of special cases — just random data.

The trick is to pick the right value’s array size. It should be large enough to not produce visible repeating patterns on the image and small enough to be generated at a reasonable speed. During my experiments, the best random value’s array length was 3.73 of the image width.

Now, let’s generate an array with random pixels and then apply them to original image:

// Pick the best array length
var rl = Math.round(ctx.canvas.width * 3.73);
var randoms = new Array(rl);

// Pre-calculate random pixels
for (var i = 0; i < rl; i++) {
   randoms[i] = Math.random() * alpha + alpha1;
}

// Apply random pixels
for (var i = 0, il = pixels.length; i < il; i += 4) {
   pixels[i] = pixels[i] * randoms[i % rl];
}

This will cut down the execution time to 80 ms in Webkit browsers and have a significant boost in Opera. Also, Opera slows down in performance when the image data array contains float values, so we have to round them with fast bit-wise OR operator.

The final code snippet looks like this:

var img = new Image;
   img.onload = function() {
   addNoise(img, 0.2); // pass 'alpha' argument
};
img.src = "stage-bg.jpg";

function addNoise(img, alpha) {
   var canvas = document.createElement('canvas');
   canvas.width = img.width;
   canvas.height = img.height;

   var ctx = canvas.getContext('2d');
   ctx.drawImage(img, 0, 0);

   var imageData = ctx.getImageData(0, 0, canvas.width, canvas.height);
   var pixels = imageData.data;
   var alpha1 = 1 - alpha;

   // Pick the best array length
   var rl = Math.round(ctx.canvas.width * 3.73);
   var randoms = new Array(rl);

   // Pre-calculate random pixels
   for (var i = 0; i < rl; i++) {
      randoms[i] = Math.random() * alpha + alpha1;
   }

   // Apply random pixels
   for (var i = 0, il = pixels.length; i < il; i += 4) {
      pixels[i] =  (pixels[i] * randoms[i % rl]) | 0;
   }

   ctx.putImageData(imageData, 0, 0);
   document.body.appendChild(canvas);
}

This code executes in about 80 ms on my laptop in Safari 5.1 for an image that is 1293×897, which is really fast. You can see the result online.

The Result

In my opinion, the result is pretty good:

  • The image size was reduced from 330 KB to 70 KB, plus 1 KB of minified JavaScript. Actually, the image could be saved at a lower quality because the noise might hide some JPEG artifacts.
  • This is a perfectly valid progressive enhancement optimization. Users with modern browsers will see a highly detailed image, while users with older browsers (such as IE 6) or with JavaScript disabled will still be able to see the image but with less detail.

The only downside of this approach is that the final image should be calculated each time the user visits the Web page. In some cases, you can store the final image as data:url in localStorage and restore it the next time the page loads. In my case, the size of the final image is 1.24 MB, so I decided not to store it and instead spend the default 5 MB of local storage on more useful data.

Blend Modes Playground

I’ve created a small playground that you can use as a starting point for your experiments and optimizations. It contains most Photoshop blend modes and opacity control. Feel free to copy any code found on this playground into your pages.

Conclusion

The technique you’ve just learned can be used in many different ways on modern Web pages. You don’t need to create many heavy, detailed images and force users to download them. Highlights, shades, textures and more can all be generated very quickly right in the user’s browser.

But use this technique wisely. Putting many unoptimized image generators on a single page could cause the browser to hang for a few seconds. You shouldn’t use this technique if you don’t really understand how it works or know what you’re doing. Always prioritize performance ahead of cool technology.

Also, note that the curtains image in this article is for demonstration purposes only. You can achieve almost the same result — a noisy image — just by placing a semi-transparent noise texture above the scene image, as shown in this example. Anyway, the point of this article was to show you how to enhance images right in the Web browser while keeping their size as small as possible.

Further Reading

(al)


© Sergey Chikuyonok for Smashing Magazine, 2011.


Testing on mobile devices without the hardware

One problem with mobile web development is testing, which I mentioned a few months ago in a post about Opera Mobile emulator and Opera Mini simulator. Emulating or simulating a specific browser is definitely better than nothing, but what about entire mobile devices?

Many developers don’t have physical access to a whole lot of different mobile devices, and buying a load of phones and tablets just for browser checking can be hard to justify. But another option is using a simulator or an emulator for browser checking. It’s not exactly the same as using the real thing, but it beats not testing at all.

I’ve been using the iOS Simulator and the Android Emulator for this. Both are available for free and do the job.

Read full post

Posted in , , .

Copyright © Roger Johansson



  •   
  • Copyright © 1996-2010 BlogmyQuery - BMQ. All rights reserved.
    iDream theme by Templates Next | Powered by WordPress