Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Strange results from using pipes #1916

Closed
ewelot opened this issue Dec 3, 2020 · 2 comments
Closed

Strange results from using pipes #1916

ewelot opened this issue Dec 3, 2020 · 2 comments

Comments

@ewelot
Copy link

ewelot commented Dec 3, 2020

I am experimenting with I/O redirections using the following simple program test.py:

#!/usr/bin/python3

import sys
import pyvips

if(len(sys.argv)>1 and sys.argv[1]!='-'):
    image = pyvips.Image.new_from_file(sys.argv[1])
else:
    source = pyvips.Source.new_from_descriptor(sys.stdin.fileno())
    image = pyvips.Image.new_from_source(source, "")

print(image.getpoint(128, 169))
image.ppmsave("x.ppm")

with a certain 16bit PPM for input (see attachment).
Running the program in two different ways produces different results:

$ test.py < test.ppm
[51505.0, 51505.0, 51505.0]
$ cat test.ppm | test.py
[12745.0, 12745.0, 12745.0]

Comparing input and output images you will recognize that some output pixels get strangely modified when running the piped command.
Any idea what is wrong with this?

(Example image test.ppm in test.zip)

@ewelot ewelot added the question label Dec 3, 2020
@jcupitt
Copy link
Member

jcupitt commented Dec 3, 2020

Yes, it looks like there's some kind of bizarre bug here. I'll investigate. Thanks for the report!

jcupitt added a commit that referenced this issue Dec 26, 2020
- ppmload was not setting interpretation, filename, etc. for files read via
  mmap
- files not read via mmap were never byteswapped
- some cleanups

see #1916
@jcupitt
Copy link
Member

jcupitt commented Dec 26, 2020

OK, I think this is fixed in 8.10 and master -- there were a couple of small errors in 16-bit ppm handling.

Thanks again for reporting this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants