I use (under Windows) the following command
magick convert -units pixelsperinch file_in -density 600 file_out
to set the dpi (no resampling, as dpi basically is, as far as I understand, just a tag that specifies pixel size) of a JPG image. It works, but I don't understand why it increases file size by several kiloBytes (an image of mine originally of 1658 kB got to 1717 kB, which is a 59 kB increase), whereas I would expect an increase, if any, of just a few bytes.
Did I get something wrong? Is it possible to change by command line (tools other than ImageMagick are welcomed too) density/dpi of a JPG without increase in file size?
Thanks in advance for any clue.
Trying to reproduce your problem:
magick convertoutput JPEG is not interlaced, and is in fact a bit smaller than Gimp's own non-interlaced. That file is the same size whether it is produced from an interlaced or non-interlaced version.So, I would think that you are converting an interlaced/progressive JPEG. Note that this also demonstrates that IM is re-encoding the file, and comparing the original and the re-encoded in Gimp shows significant differences.
In the JPEG format, the H/V definitions are encoded in 4 bytes in the header, patching that should be a SMOP in about any programming language.