What changing DPI actually does
DPI is a single number saved in the file that tells printing and layout software how many pixels to fit into each inch. Changing it rewrites that number and nothing else. The pixel dimensions stay the same, the picture looks identical on screen, and the file size barely moves.
What changes is the suggested print size. An 1800 × 1200 photo at 300 DPI prints at 6 × 4 inches; set it to 150 DPI and the same pixels spread over 12 × 8 inches. The tool shows the print size live as you pick a value, with quick options for 72, 96, 150, 300 and 600 and a box for anything from 1 to 2400.
How each format is handled
JPEG: only the file header is rewritten. The JFIF density and the EXIF resolution fields are both set, while the compressed image data is copied byte for byte, so there is no re-compression. EXIF, orientation and the color profile are kept.
PNG: the resolution is written to the pHYs chunk and the image is re-saved losslessly, keeping EXIF, text and the color profile. WebP has no dedicated DPI field, so the value goes into EXIF and the image is re-encoded, losslessly if the original was lossless and at high quality otherwise. Other inputs such as HEIC, TIFF or BMP are saved as JPEG, or PNG when they have transparency.
When a form or printer asks for 300 DPI
Print shops, publishers and some photo or document portals ask for 300 DPI. Often they are checking the field itself, and setting it here is all that is needed. But if what they really need is a sharp print at a given size, make sure the pixels are there: 300 DPI at 4 × 6 inches needs at least 1200 × 1800 pixels. Raising the DPI of a small image only makes its printed size smaller.