Content Aware Fill is one of those features of Photoshop that many users love to hate. So much so that quite a few of us have called it Content Aware Fail since it was first introduced in CS5. Personally, I’ve only found it to be really all that useful for extending clear blue skies, and even there it occasionally wants to put a branch or a building flying in the middle of nowhere. This video from the Jesús Ramirez Photoshop Training Channel, though, shows me something I never knew about Content Aware Fill. That it respects layer masks. Something which turns it into a much more reliable and useful tool. This method makes it very easy to use Content Aware Fill where you previously might not have even tried.

In the first part of the video, Jesús covers the standard way most of us use Content Aware Fill. That is, to select an area, hit shift+backspace, select Content Aware, and hit OK. And on some minor blemishes it can work quite well. But for more difficult subjects, especially where two contrasty areas meet, it gets confused easily. You can see this failing in one demonstration, attempting to remove a van partially obscured by trees and street lamps. Simply drawing a selection around the van and hitting the Content Aware Fill has some unwanted side effects. The tree expands out into the path,  parts of the lamp post are unnecessarily replicated, and it just looks bad.

And this is how “Content Aware Fail” got its nickname. But there is a way to solve this rather common issue. Essentially, the first step is to draw a selection around the area you wish to fill as you normally would. But then, instead of just filling the layer, you save your selection as a new selection. Then you start selecting other parts of the image. These are the areas from which you wish Photoshop to determine what to put in the space.

In the example shown in the video, that means other parts of similarly coloured and patterned path. Then, simply hit the new layer mask. Now you have a layer that only contains what you want to replace, and what you want to fill in that area.

Finally, load up your selection, and hit shift+backspace to bring up the fill dialogue again. Now when you choose Content Aware, it will only fill from the other visible areas in the layer. Anything that is hidden from view with the mask is hidden to Content Aware Fill. when you remove the mask, you get a more cleaner fill.

The demonstration in the video is not absolutely perfect, but these things never are in tutorials. In the real world, one would take much more time and care over the initial selection to get a cleaner result. But the technique is demonstrated perfectly. It’s a little more involved technique, but it sure beats the hell out of constantly switching between clone stamp and healing brush tools to fill in the area. Even if you ultimately go back to those tools for a little cleanup work, this method seems to work great for filling in the bulk of an area. Another point of note, is that each time you run Content Aware Fill, it’s picking somewhat randomly. So, if you fill, and don’t like the way it’s filled it, hit fill again and it’ll produce a different result. Keep filling until you get something you’re happy with.