Basically, I make two "L" frame sections on two layers where everything but the frame is transparent. Then I slide the image underneath the left & top L, so it's just under the lip of the moulding. Then I drag the right & bottom L over the rest of image. I miter the right and bottom corners with the polygonal selection tool, drawing a triangle that will remove the unwanted moulding with the clear function. Then merge the two moulding layers, but leave the image layer separate to develop drop shadows, lip shadows, etc.
The L's themselves are derived from a picture of a piece of moulding, which can be copied online, from a catalog, or (very) preferably from a recent piece of the actual moulding in your possession. Straighten up your moulding picture, remove keystoning. Even out the lighting, possibly by rubber stamping over the right side from the left side. Copy this moulding "chip" onto a large image. Butt a second copy up against the first, possibly flipping the second one left and right which makes for an easy melding of the two, but not all moulding designs will permit that. Merge this 2-up chip to another wider chip, then copy it lip-down along the top of the image for the full width. You will want to have View->Snap selected for most of this work, unless you want to go crazy.
Now you've got a long length of moulding across the top of the image. Merge the layers, copy out section, rotate the new section 90 CCW, and miter it onto the original horizontal section. Merge those two layers, all the while being sure you have used Copy (which keeps the background transparent) rather than Copy Merged which will give you solid backgrounds.
So now you've got one L. Copy it onto a new layer and rotate that layer 180. Voila.
Main thing, just always use Copy instead of Copy Merged when duplicating the little chips, which will keep the backgrounds clear. And note I have been saying "merge layers" rather than "flatten."
In common with professional framing programs that do this, you can be easily lured into thinking the moulding looks different than it really does. You should always work from actual moulding samples using your photograph.
Just ignore the color on the attached image, I'm not paid enough here to color manage.