Prerequisite: any image editor like Photoshop, Gimp, Paint etc.
Mark (entire image or part of it) - Copy - New file - Paste. (Check the menus for the exact items, may vary between editors.)
When you create a new file in Photoshop then the suggested image size will have already the dimensions of the copied image (now sitting in clipboard). Gimp behaves in the same way.