Images are necessarily rectangular. They are always dimensioned with a width and height (in pixels). Images that appear irregular shape are not, they only have a transparent background. Transparent is a magic color that doesn't show (it is simply ignored, and has no effect). For printing, a pure white background works as well, because there is no white ink, and white means, "use no ink". But white shows on the monitor screen, so a transparent background is required. A transparent background requires a GIF file.
GIF in turn requires conversion to only 256 colors (or less). JPG files are better for photographic images (16 million colors and a smaller file size), but a transparent background is only available to web browsers as a GIF file.
To create the transparent background on the Hibiscus image below, I used an indexed color Adaptive palette option to convert to 256 colors for GIF. Adaptive (sometimes called Optimized) means adapted for the colors in the particular image, and the palette for my flower image mostly contains all red and green colors. But transparent GIF can use any palette.
Most image editing programs have tools similar to each other, often named the same. To prepare a transparent GIF, we must select the background with these tools, and then fill it with the new color, so that the entire background becomes exactly one and only one color. No subtle shades of the same color, but all the exact color, because only one color can be declared transparent. This might require several tries, to select and fill several small parts of the background. Any color is OK, but the new color must be unique and not appear elsewhere in the image, because all instances of this color will become transparent. We can make it be bright pink, it doesn't matter, it will be declared transparent, but the color is really best selected to be the same color as the final web page background, to hide any tiny irregularities.
The standard Lasso Tool is often used to mark irregular areas. Don't overlook the Lasso Tool's Add/Subtract tweaking features. Those options are used to add or remove tiny increments of area by clicking the edges, and frankly, without this, the Lasso tool is hardly usable. Some tools include Smart Edge options, semi-automatic.
But to remove cluttered backgrounds, I often find it easier to just use an Erase tool, to carefully erase the background near the foreground object.
If the background is close to a solid color, the Magic Wand tool can be used. Most image programs have this, and it "selects" an area based on color. It uses a "similarity" or "tolerance" attribute value, like 15. This means that when you click on a pixel, it also selects all bordering pixels with a similar RGB value, plus or minus the similarity value. Adjacent pixels in that range are selected, by color instead of drawing a box with the mouse.
By "select", I mean mark the area with the dashed lines so that it can be manipulated, like to delete, or fill with another color with the Paint tool. It is sometimes easier to select the object, and then INVERT the selection to instead be the background around it.
The Magic Wand may be required several times in the different background areas, and a little extra cleanup necessary in a few spots. One easy way to fill the area with your specified background color is to simply hit Delete to discard selected area. It will be white, or whatever your background color was specified to be. See your program's Help menu about the use of these standard Selection tools.
The point of the transparent background is that the entire background must be the ONE exact same and unique color everywhere, so that ONE palette color index can be declared transparent. There cannot be any of that color within the remaining image, or else it will be transparent too. So sometimes people make the background a unique color, like hot pink, to reduce the risk that interior pixels will accidentally become transparent. However, this can cause visible edges if anti-aliasing is used. It is a better plan to fill the transparent background with your web page background color, so any stray pixels are not visible at the edges when displayed.
The File - Save As dialogs have Option buttons. For example, that is where the JPG and TIF compression values are found. And if a GIF file, this Option button is usually where you declare the one GIF palette index to be transparent. Some programs have menu options for it instead.