As in all things Photoshop, many different ways to get something done.
Try this - open your image and make sure it's on a transparent background:
Go to the bottom of the layer stack, click on the plus symbol in the box to add a new layer. Then drag that new empty layer underneath
the flag layer:
Now go back to your flag layer and click on it to activate it. Holding own your CTRL key (Windows) or CMND key (Mac), click on the image of the flag
You'll see marching ants appear around the image of the flag:
Now go to your top menu, click on Select > Modify > Expand, and you'll get a dialog box that will ask how many pixels to "Expand by".
This will determine how thick the border will be. I'll put in "3" so you can see more clearly what I'm doing. Then click OK.
The marching ants have now moved 3 pixels away from the selection:
With the marching ants still active, click on the bottom layer to activate it, then go up to Edit > Fill and choose black (or go to Color
and choose any color from the color palette that shows up):
Click OK:
Click CTRL+D (or CMND+D) to deactivate the ants. What you've essentially done is create a black fill layer underneath your flag layer that is 3 pixels (or 1 pixel if you choose it)
larger than your subject. You can change the border color by filling the solid color layer with another color of your choosing.
Just another way to do it....