Comments (2)
forgot to mention, adding in
def readline(self):
return self.read(100)
fixes the crash and allows imageio to open my image, by the way.
from imageio.
I'm trying to open a url of a larger JPG from an s3 storage. It's unable to ascertain the file-type
How come?
Assuming you pass a URL and the file either ends with a JPEG suffix (e.g. .jpg
) then ImageIO will try plugins known to read JPEG first and only fall back to trying everything if the "known-to-read-jpeg" plugins fail. If the URL doesn't end with a JPEG suffix, but you know it to be JPEG, you can also pass extension=".jpg"
as an additional kwarg to imopen
, imread
, etc. to set/overwrite the suffix of the resource itself.
it goes for the "try every plugin" approach:
If you already know you want to read using pillow
you can also pass plugin="pillow"
as an additional kwarg, in which case plugin selection is skipped in favour of using the plugin you specified.
But SeekableFileObject does not have readline, causing an error.
Since SeekableFileObject
is a binary file and lacks the notion of a "line of text" or an "EOL character (\n
)". As such the function reads a single line from the file doesn't make much sense in this context and we didn't implement readline
.
Using Pillow ImImagePlugin to read a file, we attempt a readline as seen here @ Pillow
The plugin you are quoting here is the plugin for reading IFUNC Image Memory
not JPEG. I have actually never encountered this format and Google and the pillow repo are suspiciously silent about it. I suspect that this is a legacy format that is no longer in active use and that should probably not be used further.
def readline(self): return self.read(100)
The problem with setting readline
to read the first 100 bytes is that this is an arbitrary cutoff. This may or may not mean something for the underlying data of the stream and will most likely leave the head at an awkward and unexpected location.
I am still not convinced we want to add readline
, but were we to do so we probably want to read the entire file. In my mind "read until you encounter the end of the current line" plus "there is no end of line for binary files" results in "read until the end of the file".
Regarding the actual problem of ImageIO being unable to read a large JPEG from S3, are you able to share a code snippet that reproduces the failure?
Walking over all plugins and trying them out is expensive and more of a last resort than something we want to do on a regular basis. If we can avoid this by doing something smart during plugin selection I'd be quite interested in this option.
from imageio.
Related Issues (20)
- imread on S3 stream fails with PIL.UnidentifiedImageError HOT 2
- ImageResource type should support bytes HOT 1
- [Bug Report] imageio v3 crashed when read hdr images after a certain number of times
- Link to the documentation in the README is broken HOT 1
- imread() fails on HTTPS, code example from documentation HOT 3
- 8bit grayscale now loaded as RGB HOT 5
- 2.31.4: documentation build fails HOT 1
- iio pyav plugin crash along with python when handling a webm file, setting format to rgba HOT 2
- It does not seem to support avif image format HOT 1
- Support for Pillow v10.1 (re: setting `image.mode`) HOT 8
- Inconsistency when reading floating point .exr image file HOT 3
- imageio.imread changes the values of graycale pixels, try to read 12-bit png grayscale image. HOT 8
- super slow video reads HOT 6
- imageio v2.33.0 requieres Pillow>=9.1.0 for GIFs HOT 1
- Trouble using freeimage plugin on MacOS arm64 HOT 2
- 2.33.1: pytest is failing in 5 units HOT 1
- [Question] What tonemapping method does the imageio library use when reading HDR images? HOT 2
- title of the gif got stacked together HOT 2
- UnicodeDecodeError if metadata is not UTF-8 encoded (pyav plugin) HOT 3
- [request] more color/palette control on GIF writing HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from imageio.