Let's suppose you have a photo you want to transform - rotate in our example - but you don't want to crop closely because you don't want to change the composition. In our case we want to fill the transparent areas with elements of the same photo. For this tutorial, we are using Photoshop CS6. Easy!
Step 1: Duplicate the Background Layer
All your processing endeavors should start with this step as a non-destructive step. Furthermore, in this tutorial specifically, we need to duplicate the layer because you cannot apply transform on the background layer. To duplicate the layer just click it and drag it to the new layer icon on the bottom right of the Layers palette or hit Ctrl + J (on PC) / Cmd +J (on Mac).
Step 2: Transform the top layer
Hide the background layer by clicking on the eye of it, then select the top layer called Layer 1. Go on the menu - Edit - Free Transform. Photoshop will frame the canvas area with 8 small square handles. Approach the mouse cursor near one of the corners and watch the cursor turn into a small arc. Click and drag to rotate left or right.
Now that we are happy with the perspective and composition, click Shift + Enter to apply the transform. But what to do with the transparent areas on the edges? Well this is where fun begins.
Step 3: Select empty / transparent areas
The easiest way to select those areas is using the Polygonal Lasso Tool (L). Hit T and start selecting around those areas. You don't have to be precise, we will let Photoshop do the math for us. Tip: Select each area alone and apply the Content-Aware Fill because you want to make sure the selection and effect are right in smaller pieces should you want to undo later.
Step 4 - Fill the selected area with Content-Aware fill
Make sure you are still on the top layer (Layer 1) and go menu - Edit - Fill. You will be prompted with the Fill dialog box.
Change the "Use:" drop down list from "Foreground Color" to "Content-Aware" and hit the OK button. That's it. Just relax and watch the magic of Content-Aware fill do its business.
If the tool introduced some other elements from the photo that you don't want (like pieces of the dog for example...), just use the Healing Brush or the Clone Stamp tools. If you have a big area you want to adjust, select the Patch tool (J), select that area and move it to a target area of your own. You can check my tutorial on the Patch Tool by following this link.