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

can output tif keep layers ? #1

Closed
jindili opened this issue Feb 17, 2022 · 4 comments
Closed

can output tif keep layers ? #1

jindili opened this issue Feb 17, 2022 · 4 comments
Labels
question Further information is requested

Comments

@jindili
Copy link

jindili commented Feb 17, 2022

some small tweak to the example on pypi page,
tif saved successful, but the layer were flattern.

Is is possible to keep the layers on ouput tif image ?

from tifffile import imread, imwrite
import psdtags

isd = psdtags.TiffImageResources.fromtiff('input_2layer.tif')
res = psdtags.TiffImageResources.fromtiff('input_2layer.tif')

image = imread('input_2layer.tif')
imwrite(
    'output_layered_tiff.tif',
    image,
    byteorder=isd.psdformat.byteorder,  # must match ImageSourceData
    photometric='rgb',  # must match ImageSourceData
    metadata=None,  # do not write any tifffile specific metadata
    extratags=[isd.tifftag(), res.tifftag()],
)
@cgohlke
Copy link
Owner

cgohlke commented Feb 17, 2022

Can you share the file? For the example I am using the layers stay layered, which is the purpose of the package. It is validated by assert isd == TiffImageSourceData.fromtiff('_layered.tif') in the docstring.

@jindili
Copy link
Author

jindili commented Feb 17, 2022

sure, here is the file
input_2layer.zip

image

@cgohlke
Copy link
Owner

cgohlke commented Feb 17, 2022

Try isd = psdtags.TiffImageSourceData.fromtiff('test_issue1.tif') instead of isd = psdtags.TiffImageResources.fromtiff('test_issue1.tif')

@cgohlke cgohlke closed this as completed Feb 17, 2022
@jindili
Copy link
Author

jindili commented Feb 17, 2022

Great!, the layer is now keeped.

Is is possible to add new layer and import data from another image file ?
I start a new issue for that.

@cgohlke cgohlke added the question Further information is requested label Feb 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants