### ImageMagick version

7.1.1-28

### Operating system

Linux

### Operating system, version and so on

MacOS 14.3.1

### Description

I am doing some automatic processing of JPEGs to reduce their quality. Consider the attached file 512x1 file:

```
$ file convertin.jpg
convertin.jpg: JPEG image data, JFIF standard 1.01, aspect ratio, density 1x1, segment length 16, Exif Standard: [TIFF image data, big-endian, direntries=1], baseline, precision 8, 512x1, components 3
```

Now, we run

```
convert convertin.jpg -quality 65% convertout.jpg
```

And the result is:

```
$ file convertout.jpg
convertout.jpg: JPEG image data, JFIF standard 1.01, aspect ratio, density 0x0, segment length 16, Exif Standard: [TIFF image data, big-endian, direntries=1], baseline, precision 8, 512x1, components 3
```

Note that density 0x0 is not allowed here: Xdensity and YDensity must both be non-zero. See the bottom paragraph on page 7 of the spec here:

https://www.w3.org/Graphics/JPEG/jfif3.pdf

This causes programs which place the JPEG file on the page (e.g PDF) to miscalculate and misrender.

Hunch: this is a miscalculation in imagemagick due to the file only being 1 pixel high.

![convertin](https://github.com/ImageMagick/ImageMagick/assets/1702581/c040b1b5-371b-4ea6-90e7-f47f9e18fad0)
![convertout](https://github.com/ImageMagick/ImageMagick/assets/1702581/9484552f-690b-461f-a0dd-5e955c9ba104)

### Steps to Reproduce

As above.

### Images

_No response_
JPEG processed by convert has disallowed "density" 0x0
This is a GitHub Issue
repo:ImageMagick
owner:ImageMagick
Title : JPEG processed by convert has disallowed "density" 0x0
Issue date:

--- start body ---
### ImageMagick version

7.1.1-28

### Operating system

Linux

### Operating system, version and so on

MacOS 14.3.1

### Description

I am doing some automatic processing of JPEGs to reduce their quality. Consider the attached file 512x1 file:

```
$ file convertin.jpg
convertin.jpg: JPEG image data, JFIF standard 1.01, aspect ratio, density 1x1, segment length 16, Exif Standard: [TIFF image data, big-endian, direntries=1], baseline, precision 8, 512x1, components 3
```

Now, we run

```
convert convertin.jpg -quality 65% convertout.jpg
```

And the result is:

```
$ file convertout.jpg
convertout.jpg: JPEG image data, JFIF standard 1.01, aspect ratio, density 0x0, segment length 16, Exif Standard: [TIFF image data, big-endian, direntries=1], baseline, precision 8, 512x1, components 3
```

Note that density 0x0 is not allowed here: Xdensity and YDensity must both be non-zero. See the bottom paragraph on page 7 of the spec here:

https://www.w3.org/Graphics/JPEG/jfif3.pdf

This causes programs which place the JPEG file on the page (e.g PDF) to miscalculate and misrender.

Hunch: this is a miscalculation in imagemagick due to the file only being 1 pixel high.

![convertin](https://github.com/ImageMagick/ImageMagick/assets/1702581/c040b1b5-371b-4ea6-90e7-f47f9e18fad0)
![convertout](https://github.com/ImageMagick/ImageMagick/assets/1702581/9484552f-690b-461f-a0dd-5e955c9ba104)

### Steps to Reproduce

As above.

### Images

_No response_
--- end body ---
