DPI is a label
The DPI in a picture file is a number in its header that says how many pixels to lay along an inch. Change it and the picture is exactly the same picture with a different label.
Where the number lives
A JPEG keeps it in its JFIF header (and often again in its Exif block); a PNG keeps it in a small chunk called pHYs, in pixels per metre. WebP has no standard place for it at all. The pixels are stored separately, and nothing about them depends on the label.
Print size = pixels ÷ pixels per inch. A density tag changes the second number on paper; it changes nothing in the picture.


