Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In pillow library, BICUBIC is not working

This is my code.

import sys, os
import numpy as np
import matplotlib.pyplot as plt
from PIL import Image
from scipy import *
sys.path.insert(0, 'C:/research')

im = Image.open('C:/research/1.jpg')
hei, wei = im.height, im.width

im_bicubic = im.resize((wei,hei), im.BICUBIC)

im.save('C:/research/1ori.jpg')            #original image
im_bicubic.save('C:/research/1bic.jpg')    #Images with bicubic applied

But I get this error.

AttributeError: 'JpegImageFile' object has no attribute 'BICUBIC'

Why is this message coming up?

.bmp, the same message pops up.

What should I do?

like image 446
ONION Avatar asked Dec 20 '25 09:12

ONION


1 Answers

You need to use PIL.Image.BICUBIC instead of im.BICUBIC.

So you need to change:

im_bicubic = im.resize((wei,hei), im.BICUBIC)

to

im.resize((wei,hei),PIL.Image.BICUBIC)

You also need to import pil like so:

import PIL
like image 115
zython Avatar answered Dec 21 '25 23:12

zython



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!