PIL cannot write mode F to jpeg

前端 未结 3 411
清酒与你
清酒与你 2021-01-03 17:28

I am taking a jpg image and using numpy\'s fft2 to create/save a new image. However it throws this error

\"IOError: cannot write mode F as JPEG\" 
         


        
3条回答
  •  谎友^
    谎友^ (楼主)
    2021-01-03 17:59

    Try convert the image to RGB:

    ...
    new_p = Image.fromarray(fft_p)
    if new_p.mode != 'RGB':
        new_p = new_p.convert('RGB')
    ...
    

提交回复
热议问题