Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Image Stacking Help
#1
Good Morning,

I'm new Python so please bear with me.
I am using the np.vstack funtion from numpy to vertically stack some images on a raspberry pi.

There is a line in the code:
 
imgs_comb = np.vstack((np.asarray(i.resize(min_shape)) for i in imgs)) 
I am trying to break down the for loop so that I can put a small delay in between the stacking of each image:

for i in imgs:
     imgs_comb = np.vstack((np.asarray(i.resize(min_shape))))
     time.sleep(1)
The code falls over when I then try and save the overall image.

Thanks for your help in advance,
Rhys
Reply
#2
Hello,
please post the full error traceback message in error tags, so we can get more details about the issue.
Reply
#3
Here's the error:
Maximum supported image dimension is 65500 pixels
Traceback (most recent call last):
File "/home/pi/Documents/Rentokil CFC/Dev/Image Attach Vertical Stack.py", line 43, in <module>
imgs_comb.save('/home/pi/Documents/Rentokil CFC/Dev/trial.jpg')
File "/usr/lib/python3/dist-packages/PIL/Image.py", line 1728, in save
save_handler(self, fp, filename)
File "/usr/lib/python3/dist-packages/PIL/JpegImagePlugin.py", line 734, in _save
ImageFile._save(im, fp, [("jpeg", (0, 0)+im.size, 0, rawmode)], bufsize)
File "/usr/lib/python3/dist-packages/PIL/ImageFile.py", line 495, in _save
raise IOError("encoder error %d when writing image file" % s)
OSError: encoder error -2 when writing image file

So it's trying to say that image is too big.
Not sure why it works OK with the first line of code.
Is the way I'm breaking down the for loop creating another dimension maybe?

Rhys
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Stacking Problem in a game. HelloTobi22 2 1,008 Aug-05-2022, 09:48 AM
Last Post: HelloTobi22
  Stacking generators Ofnuts 2 19,638 Sep-18-2016, 08:36 PM
Last Post: Ofnuts

Forum Jump:

User Panel Messages

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