From near the beginning of the PIL Tutorial:
Once you have an instance of the Image class, you can use the methods defined by this class to process and manipulate the image. For example, let's display the image we just loaded:
>>> im.show()
Update:
Nowadays the Image.show() method is formally documented in the Pillow fork of PIL along with an explanation of how it's implemented on different OSs.
Image Processing in Python with Pillow
python - How to show PIL images on the screen? - Stack Overflow
python - How can I save an image with PIL? - Stack Overflow
Using PIL (Pillow) and Image Resolution
Videos
From near the beginning of the PIL Tutorial:
Once you have an instance of the Image class, you can use the methods defined by this class to process and manipulate the image. For example, let's display the image we just loaded:
>>> im.show()
Update:
Nowadays the Image.show() method is formally documented in the Pillow fork of PIL along with an explanation of how it's implemented on different OSs.
I tested this and it works fine for me:
from PIL import Image
im = Image.open('image.jpg')
im.show()
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')
You should be able to simply let PIL get the filetype from extension, i.e. use:
j.save("C:/Users/User/Desktop/mesh_trans.bmp")
I'm modifying images using PIL. I want mainly to convert the format of images, like jpg to png. I noticed that the resolution seems to change after using PIL.
I found this image of a tiger and got that its resolution is 350 pixels/inch.
Here is my code.
I wanted to see what effect changing the resolution/"quality" would have. It turns out that all images from PIL are read (via Preview on MacOS) as having a resolution of 72 pixels/inch no matter the desired quality.
quality = 1
Quality 1 image has resolution 72 pixels/inch
quality = 95
Quality 95 image has resolution 72 pixels/inch
If this is a false reading of the resolution, I'd be curious to know. In any case, my question is how, if even possible, can one adjust the resolution of the image via PIL?