The error regarding the file extension has been handled, you either use BMP (without the dot) or pass the output name with the extension already. Now to handle the error you need to properly modify your data in the frequency domain to be saved as an integer image, PIL is telling you that it doesn't accept float data to save as BMP.

Here is a suggestion (with other minor modifications, like using fftshift and numpy.array instead of numpy.asarray) for doing the conversion for proper visualization:

import sys
import numpy
from PIL import Image

img = Image.open(sys.argv[1]).convert('L')

im = numpy.array(img)
fft_mag = numpy.abs(numpy.fft.fftshift(numpy.fft.fft2(im)))

visual = numpy.log(fft_mag)
visual = (visual - visual.min()) / (visual.max() - visual.min())

result = Image.fromarray((visual * 255).astype(numpy.uint8))
result.save('out.bmp')
Answer from mmgp on Stack Overflow
🌐
Pillow Documentation
pillow.readthedocs.io › en › stable › reference › Image.html
Image module - Pillow (PIL Fork) 12.2.0 documentation
This method returns raw image data derived from Pillow’s internal storage. For compressed image data (e.g. PNG, JPEG) use save(), with a BytesIO parameter for in-memory data.
Discussions

Using PIL what is the easiest way to save a jpg File to a folder?
Why do you need to use PIL? Are you editing and manipulating the file before saving or do you literally just need to copy an existing file? More on reddit.com
🌐 r/learnpython
3
2
December 21, 2020
python - Saving Image with PIL - Stack Overflow
PIL isn't an attribute of newImg1 but newImg1 is an instance of PIL.Image so it has a save method, thus the following should work. More on stackoverflow.com
🌐 stackoverflow.com
Saving PNG images with PIL is 4 times slower than saving them with OpenCV
What did you do? I want to save an image to disk and noticed a severe performance bottleneck for the part of my code that used PIL for saving images compared to a similar part in my codebase that u... More on github.com
🌐 github.com
36
January 25, 2022
PIL.Image.save ignores parameters
What did you do? I want to read then write a png image while preserving its Image.info dictionary items like gamma using PIL.Image.save. What did you expect to happen? New image to have same Image.... More on github.com
🌐 github.com
4
March 24, 2022
🌐
GeeksforGeeks
geeksforgeeks.org › python › python-pil-image-save-method
Python PIL | Image.save() method - GeeksforGeeks
December 23, 2025 - Example 2: This example saves the image with a lower JPEG quality to reduce file size. ... A new file compressed.jpg with reduced quality. Explanation: quality=40 tells the JPEG writer to compress the image more, producing a smaller file. Example 3: Saving an Image Using an Explicit Format when using a file object instead of a filename, the format must be explicitly provided. ... from PIL import Image img = Image.open("flower.jpg") with open("saved_image.bin", "wb") as f: img.save(f, format="JPEG")
🌐
Codecademy
codecademy.com › docs › python:pillow › image module › .save()
Python:Pillow | Image Module | .save() | Codecademy
March 27, 2025 - In the Pillow library, the .save() method saves an image to a specified filename.
🌐
Pillow Documentation
pillow.readthedocs.io › en › stable › handbook › image-file-formats.html
Image file formats - Pillow (PIL Fork) 12.2.0 documentation
If present and set to “BLP1”, images will be saved as BLP1. Otherwise, images will be saved as BLP2. Pillow reads and writes Windows and OS/2 BMP files containing 1, L, P, or RGB data. 16-colour images are read as P images. Support for reading 8-bit run-length encoding was added in Pillow 9.1.0.
Find elsewhere
🌐
GitHub
github.com › python-pillow › Pillow › discussions › 7896
Feature request: adding quality='keep' to Image.save() with JPEG2000 · python-pillow/Pillow · Discussion #7896
Is your goal to be able to save a JPEG2000 image without "losing quality" aka "modifying the pixels"? I think Pillow should already do that, provided that you haven't set irreversible=True.
Author   python-pillow
🌐
Python Examples
pythonexamples.org › pillow-save-image
Save Image with Pillow in Python
To save an image in Python with Pillow library, you can use Image.save() method.
🌐
GitHub
github.com › python-pillow › Pillow › issues › 5986
Saving PNG images with PIL is 4 times slower than saving them with OpenCV · Issue #5986 · python-pillow/Pillow
January 25, 2022 - 100%|██████████| 50/50 [00:26<00:00, 1.91it/s] Total time for PIL: 26.21s 100%|██████████| 50/50 [00:06<00:00, 8.00it/s] Total time for OpenCV: 6.24s Images are equal: True
Author   apacha
🌐
Pillow Documentation
pillow.readthedocs.io › en › stable › handbook › tutorial.html
Tutorial - Pillow (PIL Fork) 12.2.0 documentation
To save a file, use the save() method of the Image class. When saving files, the name becomes important. Unless you specify the format, the library uses the filename extension to discover which file storage format to use. import os, sys from ...
🌐
DEV Community
dev.to › doridoro › in-django-model-save-an-image-with-pillow-pil-library-5hbo
In Django model: save an image with Pillow (PIL) library - DEV Community
June 28, 2024 - #django #pillow · The save method in Django models is designed to persist the model instance to the database. By default, it handles basic saving operations, but it can be overridden to add additional functionality or to customize the saving process. In this Picture model, we have overridden the save method to include specific image handling logic before the actual save operation is performed.
🌐
TutorialsPoint
tutorialspoint.com › python_pillow › python_pillow_working_with_images.htm
Python Pillow - Working With Images
The Image module of the pillow library provides the save() method, allowing you to to save the specified image object into the specified location of the memory or local system.
🌐
Python Guides
pythonguides.com › python-save-an-image-to-file
How to Save Images in Python
January 27, 2026 - from PIL import Image import requests from io import BytesIO # Imagine we are processing a high-res photo of the Grand Canyon # For this example, I'll open an image from a URL and save it locally url = "https://images.unsplash.com/photo-1474044159687-1ee9f3a51722" response = requests.get(url) img = Image.open(BytesIO(response.content)) # I always recommend verifying the format before saving print(f"Original Format: {img.format}") # Saving the image as a JPEG with high quality img.save("grand_canyon_processed.jpg", "JPEG", quality=95) # You can also save it as a PNG to preserve transparency img.save("grand_canyon_processed.png", "PNG")
🌐
GitHub
github.com › python-pillow › Pillow › issues › 6156
PIL.Image.save ignores parameters · Issue #6156 · python-pillow/Pillow
March 24, 2022 - As documented in Image.save and PNG file format · New image has empty Image.info dictionary. ... from PIL import Image img = Image.open("sample.png") # Sample image provided below code block info = img.info img.save("output.png", **info) output_info = Image.open("output.png").info print(info) # {'gamma': 2147.48365} print(output_info) # {} print(output_info == info) # False, should be True
Author   freshmre
🌐
Pillow
pillow.readthedocs.io › en › latest › reference › Image.html
Image module - Pillow (PIL Fork) 12.3.0.dev0 documentation
This method returns raw image data derived from Pillow’s internal storage. For compressed image data (e.g. PNG, JPEG) use save(), with a BytesIO parameter for in-memory data.
🌐
Janakiev
janakiev.com › blog › python-pilow-download-image
Downloading Images with Python, PIL, Requests, and Urllib - njanakiev
April 12, 2023 - import io import requests from PIL import Image w, h = 800, 600 filepath = "image.jpg" url = "https://images.unsplash.com/photo-1465056836041-7f43ac27dcb5?w=720" r = requests.get(url, stream=True) if r.status_code == 200: img = Image.open(io.BytesIO(r.content)) # Do something with image # Save image to file img.save(filepath) Sometimes you cannot install the requests library and need to use the rich Python standard library.
🌐
GeeksforGeeks
geeksforgeeks.org › python › python-pil-image-open-method
Python PIL | Image.open() method - GeeksforGeeks
October 7, 2025 - from PIL import Image img = Image.open("example.jpg") # Save it in PNG format img.save("new_image.png")