Questions tagged [python-imageio]

Imageio is a Python library that provides an easy interface to read and write a wide range of image data including animated images, volumetric data, and scientific formats. Make to use this tag for question related to it.

191 questions
5
votes
1 answer

How to resize an image using imageio?

Consider an image img of type imageio.core.util.Array. The shape of img is (256, 256, 3). I want to resize it to (128, 128, 3). I tried at least the following three: img.resize(img_res, pilmode="RGB") img.resize(img_res) img = cv2.resize(img,…
hanugm
  • 1,127
  • 3
  • 13
  • 44
5
votes
1 answer

How to make gif from circular masked images?

Download Zip with Images I have a folder with circular masked png images: Usually I use this code to make gifs: import imageio import os imglist = [] images = [] path = ('\\').join(__file__.split('\\')[:-1]) + '\\' + 'images\\' for r, _, f in…
5
votes
1 answer

VOC2012: PIL Image.open converts PNG to 2d array

I am working with VOC2012 dataset. The input image is in PNG format which has a shape of (375, 500, 4) when I use imageio to open the image. When I use PIL to open the image, then suddenly the shape becomes (500, 375). PNG images should have four…
5
votes
2 answers

how to open image as rgb file when using imageio

I have an existing code segment reading image using scipy.misc imref = misc.imread(self.file_image, False, "RGB") If I would like to replace it with imageio, how to do that, can I just use imref = imageio.imread(self.file_image, False). I am not…
user288609
  • 12,465
  • 26
  • 85
  • 127
4
votes
2 answers

How to resize images with imageio to get proper ICO files?

I want to save ICO files from images. imageio is working perfectly, but for horizontal images, it gave me an error. This is my code: import imageio image = imageio.imread('image.png') imageio.imwrite("image.ico", image)
Eklavya Chandra
  • 108
  • 1
  • 11
4
votes
1 answer

Record screen with Python into GIF

This records a 5-second screencast of a 300x300px top-left square of the screen (10 frame per second): import time, numpy as np, pyautogui, imageio t0 = time.time() with imageio.get_writer('test.gif', mode='I', duration=0.1) as writer: while…
Basj
  • 41,386
  • 99
  • 383
  • 673
4
votes
0 answers

How to fix in mimwrite raise RuntimeError("Zero images were written.") using imageio?

I was given code to combine png files to create a gif. I've had it working on another computer using different png files but when I can to use it on another project I get an error that I don't understand (I'm still learning). Can anyone help? The…
4
votes
0 answers

io.UnsupportedOperation: seek

I am trying download all the images given in the dataset. https://www.kaggle.com/crowdflower/twitter-user-gender-classification Check for the downloads It is a CSV file containing 20000 datasets with 26 columns I ran this script import…
Praba
  • 390
  • 1
  • 4
  • 13
4
votes
1 answer

ImageIO - get image Width and Height from loaded image

I need to get width and height of an image using imageio, loading an image into imageio with imread, how can I get the height and width of the image or in another word the resolution of the image? in the documentation, it mentions it will return…
Bear
  • 550
  • 9
  • 25
4
votes
2 answers

Convert numpy.ndarray into imageio.core.util.Image

I was trying to resize the input image using OpenCV but I am having problems converting the resized np array into the original format. image = imageio.imread(filename) # image_re = cv2.resize(image, (256, 256))…
Pablo Gonzalez
  • 673
  • 2
  • 10
  • 24
4
votes
0 answers

Python ImageIO: Too many open files

I am using imageio in python in order to open all video files in a directory and convert them to numpy arrays. Here is the script I am using: 1 from __future__ import print_function 2 from avi_to_numpy import * 3 from os import listdir 4…
Alex
  • 1,233
  • 2
  • 17
  • 27
3
votes
1 answer

How to get video metadata from bytes using imageio.v3?

I am creating a python class to process videos received from a http post. The videos can be from a wide range of sizes, 10 seconds up to 10 hours. I am looking for a way to get video metadata such as fps, height, width etc. without having to store…
brenodacosta
  • 389
  • 2
  • 13
3
votes
1 answer

How to seek a frame in video using `imageio`?

I have a video and I would like to extract only specific frames from the video. Currently what I do is: index = [1,2,3,4,5,6,7,8] img_list = [] for i, frame in enumerate(iio.imiter("imageio:cockatoo.mp4")): if i in index: …
user42
  • 871
  • 1
  • 10
  • 28
3
votes
4 answers

Grayscale image not a jpeg

I created a greyscale image like this def create_new_image(size, luminance): width, height = size black_frame = int(luminance) * np.ones((width, height, 1), dtype=np.uint8) return black_frame Where luminance is element of [0, 255] I…
Jürgen K.
  • 3,427
  • 9
  • 30
  • 66
3
votes
0 answers

OSError: encoder error -2 when writing image file

Getting following error while writing an image file: imageio.imwrite(fname,g); File "C:\Users\Himanshu\AppData\Local\Programs\Python\Python37-32\lib\site-packages\imageio\core\functions.py", line 261, in…
1
2
3
12 13