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
🌐
GeeksforGeeks
geeksforgeeks.org › python › python-pil-image-save-method
Python PIL | Image.save() method - GeeksforGeeks
December 23, 2025 - It allows you to save an edited, resized, or newly created image using a filename or a file object. The format is usually detected from the file extension unless explicitly provided. Note: We will be using a sample image "eyes.jpg", to download click here and make sure to keep the image in the same folder as your python script.
Discussions

How to save an image in Python
https://pillow.readthedocs.io/en/stable/reference/Image.html Try images.show () or images.save ('my_image.png') to save to disk. More on reddit.com
🌐 r/StableDiffusion
2
3
October 14, 2023
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
Save this answer. ... Show activity on this post. 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
How to save an image with the Python Image Library - Stack Overflow
I am a beginner in Python, so this question might be stupid but unfortunately I can't figure it out on my own. With the following script I want to create a black image and save it under the following More on stackoverflow.com
🌐 stackoverflow.com
🌐
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. The filename, provided by the user or the code writer, determines the format in which the image is saved.
🌐
Python Guides
pythonguides.com › python-save-an-image-to-file
How to Save Images in Python
January 27, 2026 - I recommend using absolute paths or the os library to define exactly where the image should go. Another common pitfall is file permissions. Ensure your Python script has the right to “Write” to the folder, especially if you are working on a shared server or a restricted Windows directory. In this tutorial, I showed you how to save images using Pillow, OpenCV, Matplotlib, and the Requests library.
🌐
Cloudinary
cloudinary.com › home › 6 ways to save images in python
6 Ways to Save Images in Python | Cloudinary
November 23, 2025 - By combining urllib with other libraries like os or io, you can save the downloaded image data to your local filesystem. While it provides basic functionality for downloading images, more specialized image processing tasks may require additional libraries like Pillow or OpenCV. Note: In Python 3.5, you’ll need to install the requests library by running pip3 install requests
🌐
Java2Blog
java2blog.com › home › python › save image to file in python
Save Image to File in Python - Java2Blog
December 4, 2023 - Pickle is used for serializing and de-serializing Python object structures, making it useful for image data storage. Serializing an image from C:/images/source/pickle_image.jpg to D:/images/target/: ... Import Libraries: pickle for serialization, imageio for reading the image, and os for file management. Image Serialization: Read and serialize the image using pickle.dump, and save it to the target directory.
Find elsewhere
🌐
Reddit
reddit.com › r/stablediffusion › how to save an image in python
r/StableDiffusion on Reddit: How to save an image in Python
October 14, 2023 -

Hey guys, quick question: How do I save my image in python. I am not a programmer so forgive me this probably very easy question.. :D

Here is my Code so far, I copied it from a Huggingface Thread:

from diffusers import DiffusionPipeline
import torch
from PIL import Image
import torchvision.transforms as transforms
import matplotlib.pyplot as plt

pipe = DiffusionPipeline.from_pretrained("stabilityai/stable-diffusion-xl-base-1.0", torch_dtype=torch.float16, use_safetensors=True, variant="fp16")
pipe.to("cuda")

# if using torch < 2.0
# pipe.enable_xformers_memory_efficient_attention()

prompt = ""

images = pipe(prompt=prompt).images[0]

Everything works fine. It's just, that the image doesn't show up.

🌐
Apify
blog.apify.com › save-image-python
How to save an image with Python - with code examples
February 20, 2024 - The shutil module offers several high-level operations on files and collections of files. Let's use the requests library to download an image and the shutil module to save it locally in binary mode efficiently. Shutil is a part of the Python standard libraries, so we don't need to explicitly install it.
🌐
Appdividend
appdividend.com › pil-image-save
PIL Image.save(): Saving JPEG File in Python
November 20, 2025 - To save an image in JPEG format in Python, use the PIL library’s Image.save() method.
🌐
Roboflow
roboflow.com › home › save an image with cv2.imwrite
Save an Image with cv2.imwrite (OpenCV) | Roboflow
Save an image to a file with cv2.imwrite in OpenCV: pass the file name and the image. Python example included.
🌐
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 › saving-a-plot-as-an-image-in-python
Saving a Plot as an Image in Python - GeeksforGeeks
July 23, 2025 - Create a Function for Converting a passed figure to a PIL Image. Save the return image in a variable by passing a plot in the created function for Converting a plot to a PIL Image.
🌐
ScrapingBee
scrapingbee.com › home › blog › how to download an image with python?
How to download an image with Python? | ScrapingBee
January 14, 2026 - Plenty of beginners just do open("image.jpg") for everything, but once you start handling multiple formats or big batches, that falls apart instantly. ... This pattern works well for Python save image, save an image Python, and Python save image from URL workflows.
🌐
Py5coding
py5coding.org › reference › py5image_save.html
Py5Image.save() — py5 documentation
October 28, 2024 - Save the Py5Image object to an image file. This method uses the Python library Pillow to write the image, so it can save images in any format that that library supports.
🌐
Stack Overflow
stackoverflow.com › questions › 29600697 › how-to-save-an-image-with-the-python-image-library
How to save an image with the Python Image Library - Stack Overflow
def create_image(x=1000, y=10, path="C:/Users/bsimon/Desktop/", filename="black", filetype="png"): img = Image.new('RGB', (x,y), "black") fullpath = os.path.join(path, filename + '.' + filetype) img.save(fullpath) ... Pass whatever arguments (with keyword) you want, and it'll use the default values for all the others (just as you were already using the default values for x and y). Notice that you always need quotes around string literals in Python.
🌐
Plotly
plotly.com › python › static-image-export
Static image export in Python
Plotly allows you to save static images of your plots. Save the image to your local computer, or embed it inside your Jupyter notebooks as a static image.