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

Write a huge (500,000 X 100,000) as .svs or .tiff format #69

Closed
deepakanandece opened this issue Oct 11, 2018 · 15 comments
Closed

Write a huge (500,000 X 100,000) as .svs or .tiff format #69

deepakanandece opened this issue Oct 11, 2018 · 15 comments
Labels

Comments

@deepakanandece
Copy link

I am new to pyvips. I am inable to find the syntax for writing these huge images in *.svs or *.tiff format. Please help.

@jcupitt
Copy link
Member

jcupitt commented Oct 11, 2018

Hello, you can't write SVS, it's a read-only format.

Do you want a command-line? Try:

vips black x.tif 500000 100000

It'll obviously take a while!

@jcupitt
Copy link
Member

jcupitt commented Oct 11, 2018

Oh, sorry, pyvips. Try:

import pyvips

huge_image = pyvips.Image.black(500000, 100000)
huge_image.write_to_file("x.tif")

@deepakanandece
Copy link
Author

Thanks for the quick reply. I have a numpy array of size that big. I want to write it as to be read compatibly by openslide which leaves me with an option of only tiff images.

@jcupitt
Copy link
Member

jcupitt commented Oct 11, 2018

You can go numpy -> vips like this:

https://github.com/libvips/pyvips/blob/master/examples/pil-numpy-pyvips.py

You probably saw.

I would save as a tiled jpeg bigtiff, so:

huge_image.tiffsave("x.tif", tile=true, compression=jpeg, bigtiff=true)

@deepakanandece
Copy link
Author

deepakanandece commented Oct 11, 2018

I got this error:
I used numpy to vips conversion and wrote it into pyimg. sourcenorm is an numpy array for a color image. Here s is a string containing path for saving the .tif extension file.

pyimg = numpy2vips(sourcenorm)
 pyimg.tiffsave(s, tile=True, compression='jpeg', bigtiff=True)
  File "/home/deepakanand/.local/lib/python2.7/site-packages/pyvips/vimage.py", line 799, in call_function
    return pyvips.Operation.call(name, self, *args, **kwargs)
  File "/home/deepakanand/.local/lib/python2.7/site-packages/pyvips/voperation.py", line 132, in call
    op = Operation.new_from_name(operation_name)
  File "/home/deepakanand/.local/lib/python2.7/site-packages/pyvips/voperation.py", line 60, in new_from_name
    raise Error('no such operation {0}'.format(operation_name))
pyvips.error.Error: no such operation tiffsave
  VipsOperation: class "tiffsave" not found

@jcupitt
Copy link
Member

jcupitt commented Oct 11, 2018

Looks like your libvips has been built without tiff support. Did you make it yourself? Check the output of libvips configure and make sure you have the libtiff headers.

@deepakanandece
Copy link
Author

Thanks for such response.
Can you provide me a stepwise instruction for rebuilding it. I was not able to build it as one go. There were errors. However, later it started to work.
I am running Ubuntu 16.04, python 2.7.

@jcupitt
Copy link
Member

jcupitt commented Oct 11, 2018

There's a chapter in the docs:

https://libvips.github.io/libvips/install.html#building-libvips-from-a-source-tarball

it's like building any linux project.

but are you sure you need to build libvips? The version that's included with Ubuntu 16.04 should work.

@deepakanandece
Copy link
Author

If libvips is already there then how to add support for Tiffsave.

@jcupitt
Copy link
Member

jcupitt commented Oct 11, 2018

Because you have installed your own libvips which does not have tiff support. Remove it and install the Ubuntu one instead.

@deepakanandece
Copy link
Author

Cool! I will do it and get back to you. Thanks again. You are one of the most active guys in handling issues.

@deepakanandece
Copy link
Author

deepakanandece commented Oct 11, 2018

I was able to write the image as .tif format but openslide fails to read it. Do I need to read the created files using vips only?

@deepakanandece
Copy link
Author

Openslide recognizes the file if it has multiple layers. Thanks a lot.

@jcupitt
Copy link
Member

jcupitt commented Oct 11, 2018

Ah OK, good to know. That's with pyramid=True I guess?

@deepakanandece
Copy link
Author

Yes by doing pyramid=True. However is there any way to only restrict the number of layers alongwith pyramid? It gives 10 layers by default.

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

No branches or pull requests

2 participants