Repository: python-pillow/Pillow

Issue:
Since 10.0.1, saving an image as a JPEG does not always result in files of the same size
<!--
Thank you for reporting an issue.

Follow these guidelines to ensure your issue is handled properly.

If you have a ...

1.  General question: consider asking the question on Stack Overflow
    with the python-imaging-library tag:

    * https://stackoverflow.com/questions/tagged/python-imaging-library

    Do not ask a question in both places.

    If you think you have found a bug or have an unexplained exception
    then file a bug report here.

2.  Bug report: include a self-contained, copy-pastable example that
    generates the issue if possible. Be concise with code posted.
    Guidelines on how to provide a good bug report:

    * https://stackoverflow.com/help/mcve

    Bug reports which follow these guidelines are easier to diagnose,
    and are often handled much more quickly.

3.  Feature request: do a quick search of existing issues
    to make sure this has not been asked before.

We know asking good questions takes effort, and we appreciate your time.
Thank you.
-->

### What did you do?
Using Pillow 10.0.1 and above, saving an image as a JPEG does not always result in the same number of bytes being written.

### What did you expect to happen?
Saving the same image multiple times as a JPEG would result in files of the same size.

### What actually happened?
The file sizes differ

### What are your OS, Python and Pillow versions?

* OS: macOS Ventura 13.6
* Python: 3.9.6
* Pillow: 10.0.1

<!--
Please include **code** that reproduces the issue and whenever possible, an **image** that demonstrates the issue. Please upload images to GitHub, not to third-party file hosting sites. If necessary, add the image to a zip or tar archive.

The best reproductions are self-contained scripts with minimal dependencies. If you are using a framework such as Plone, Django, or Buildout, try to replicate the issue just using Pillow.
-->

```python
from io import BytesIO

from PIL import Image

image = Image.new(mode="RGB", size=(1024, 1024), color="red")

for _ in range(10):
    output = BytesIO()
    image.save(output, format="jpeg")
    output.seek(0)
    print(len(output.read()))
```

#### Actual Output:
```
17013
17014
17014
17014
17014
17013
17013
17014
17014
17014
```

### Expected output:
The number of bytes should be the same for each iteration.




Discussion:

Resolving patch:
diff --git a/winbuild/build_prepare.py b/winbuild/build_prepare.py
--- a/winbuild/build_prepare.py
+++ b/winbuild/build_prepare.py
@@ -110,9 +110,9 @@ def cmd_msbuild(
 DEPS = {
     "libjpeg": {
         "url": SF_PROJECTS
-        + "/libjpeg-turbo/files/3.0.0/libjpeg-turbo-3.0.0.tar.gz/download",
-        "filename": "libjpeg-turbo-3.0.0.tar.gz",
-        "dir": "libjpeg-turbo-3.0.0",
+        + "/libjpeg-turbo/files/3.0.1/libjpeg-turbo-3.0.1.tar.gz/download",
+        "filename": "libjpeg-turbo-3.0.1.tar.gz",
+        "dir": "libjpeg-turbo-3.0.1",
         "license": ["README.ijg", "LICENSE.md"],
         "license_pattern": (
             "(LEGAL ISSUES\n============\n\n.+?)\n\nREFERENCES\n=========="


Test patch: