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.
🌐
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.
🌐
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 ...
🌐
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
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.
Find elsewhere
🌐
Pillow Documentation
pillow.readthedocs.io › en › stable › _modules › PIL › Image.html
PIL.Image - Pillow (PIL Fork) 12.1.1 documentation
[docs] def save( self, fp: StrOrBytesPath | IO[bytes], format: str | None = None, **params: Any ) -> None: """ Saves this image under the given filename. If no format is specified, the format to use is determined from the filename extension, if possible. Keyword options can be used to provide additional instructions to the writer. If a writer doesn't recognise an option, it is silently ignored. The available options are described in the :doc:`image format documentation <../handbook/image-file-formats>` for each writer.
🌐
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.
🌐
Bitbucket
hhsprings.bitbucket.io › docs › programming › examples › python › PIL › Image__class_Image.html
Image Module - class Image — Pillow (PIL) examples
Saves this image under the given filename: from PIL import Image img = Image.new("RGB", (16, 16)) img.save("out.jpg") If the filename extension is not a standard, you can pass format argument explicitly: from PIL import Image img = Image.new("RGB", (16, 16)) img.save("out.thumbnail", "JPEG") Possible formats are described in Image file formats.
🌐
Pillow
pillow.readthedocs.io › en › latest › handbook › tutorial.html
Tutorial - Pillow (PIL Fork) 12.3.0.dev0 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 ...
🌐
Pillow Documentation
pillow.readthedocs.io › en › stable › releasenotes › 3.0.0.html
3.0.0 (2015-10-01) - Pillow (PIL Fork) 12.0.0 documentation
There is now support for saving multipage images in the GIF and PDF formats. To enable this functionality, pass in save_all=True as a keyword argument to the save:
🌐
Python Examples
pythonexamples.org › pillow-save-image
Save Image with Pillow in Python
In this tutorial, you will learn how to use Image.save() function to save an image object as an image file in your local file system. ... Import Image module from Pillow library.
🌐
GitHub
github.com › python-pillow › Pillow › issues › 6156
PIL.Image.save ignores parameters · Issue #6156 · python-pillow/Pillow
March 24, 2022 - 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 › handbook › image-file-formats.html
Image file formats - Pillow (PIL Fork) 12.2.0.dev0 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.
🌐
Real Python
realpython.com › image-processing-with-the-python-pillow-library
Image Processing With the Python Pillow Library – Real Python
January 8, 2025 - This code saves animation.gif to file, and you can then open the GIF file with any image software. The GIF should loop by default, but on some systems you’ll need to add the keyword argument loop=0 to .save() to make sure the GIF loops. The animation that you get is the following one: The three squares with different colors merge into a single white square. Can you create your own animation using different shapes and different colors? You’ve learned how to use Pillow to deal with images and perform image processing.
🌐
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.
🌐
GitHub
github.com › python-pillow › Pillow › blob › main › docs › handbook › tutorial.rst
Pillow/docs/handbook/tutorial.rst at main · python-pillow/Pillow
A second argument can be supplied to the :py:meth:`~PIL.Image.Image.save` method which explicitly specifies a file format.
Author   python-pillow