Python Forum
PIL Image / python-resize-image AttributeError
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
PIL Image / python-resize-image AttributeError
#1
Hi, I am getting an Attribute Error when using the PIL mage module. Not sure what the cause is as the no attribute of 'upper' is not written in the code, and when searching for similar errors, the missing attribute seems to be written in the code.

for file in glob.glob("*.png"):
  img = Image.open(file)
  rec = resizeimage.resize_crop(img, [200, 100])
  filename = "rec_"+ file 
  img.save(output + filename, rec)
Error:
AttributeError Traceback (most recent call last) <ipython-input-23-f08ed3820260> in <module>() 3 rec = resizeimage.resize_crop(img, [200, 100]) 4 filename = "rec_"+ file ----> 5 img.save(output + filename, rec) /usr/local/lib/python3.6/dist-packages/PIL/Image.py in save(self, fp, format, **params) 2084 raise ValueError("unknown file extension: {}".format(ext)) 2085 -> 2086 if format.upper() not in SAVE: 2087 init() 2088 if save_all: AttributeError: 'Image' object has no attribute 'upper'
What is the cause and solution to this error? Would be much appreciated.
Reply
#2
rec parameter should specify the format of an image, e.g. "png", "jpeg" etc. In your case, you passed an Image-instance (rec is an Image instance). Try, e.g. img.save(output+filename, 'png')
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
Photo image error pyc0de 2 252 Mar-23-2024, 06:20 PM
Last Post: pyc0de
  Using OpenCV and image path is invalid AudunNilsen 5 546 Mar-18-2024, 05:28 PM
Last Post: snippsat
  Count image's colors very fast flash77 18 1,549 Mar-05-2024, 06:12 PM
Last Post: deanhystad
  Convert numpy array to image without loading it into RAM. DreamingInsanity 7 5,868 Feb-08-2024, 09:38 AM
Last Post: paul18fr
  error "cannot identify image file" part way through running hatflyer 0 666 Nov-02-2023, 11:45 PM
Last Post: hatflyer
  Mirror Video Image in realtime makingwithheld 1 427 Oct-30-2023, 02:45 PM
Last Post: Larz60+
  howto get size of a ctk image? janeik 2 855 Oct-03-2023, 03:49 AM
Last Post: janeik
  Use of PIL.Image nafshar 12 2,104 Sep-07-2023, 11:02 PM
Last Post: nafshar
Question image manipulation (cropping and MetaData) SpongeB0B 4 1,154 Jul-03-2023, 06:35 PM
Last Post: SpongeB0B
  Python: Regex is not good for re.search (AttributeError: 'NoneType' object has no att Melcu54 9 1,470 Jun-28-2023, 11:13 AM
Last Post: Melcu54

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020