Read and write layered TIFF ImageSourceData and ImageResources tags

Overview

Read and write layered TIFF ImageSourceData and ImageResources tags

Psdtags is a Python library to read and write the Adobe Photoshop(r) specific ImageResources (#34377) and ImageSourceData (#37724) TIFF tags, which contain image resource blocks, layer and mask information found in a typical layered TIFF file created by Photoshop.

The format is specified in the Adobe Photoshop TIFF Technical Notes (March 22, 2002) and Adobe Photoshop File Formats Specification (November 2019).

Adobe Photoshop is a registered trademark of Adobe Systems Inc.

Author: Christoph Gohlke
Organization: Laboratory for Fluorescence Dynamics, University of California, Irvine
License: BSD 3-Clause
Version: 2022.1.14

Requirements

This release has been tested with the following requirements and dependencies (other versions may work):

Revisions

2022.1.14
Initial release.

Notes

The API is not stable yet and might change between revisions.

This module has been tested with a limited number of files only.

Consider psd-tools and pytoshop for working with Adobe Photoshop PSD files.

Examples

Read the ImageSourceData tag value from a layered TIFF file and iterate over all the channels:

>>> isd = TiffImageSourceData.fromtiff('LayeredTiff.tif')
>>> for layer in isd.layers:
...     layer.name
...     for channel in layer.channels:
...         ch = channel.data
'Background'
'Reflect1'
'Reflect2'
'image'
'Layer 1'
'ORight'
'I'
'IShadow'
'O'

To view the layer and mask information in a layered TIFF file from a command line, run:

python -m psdtags LayeredTiff.tif
You might also like...
CTF challenges and write-ups for MicroCTF 2021.

MicroCTF 2021 Qualifications About This repository contains CTF challenges and official write-ups for MicroCTF 2021 Qualifications. License Distribute

a reccurrent neural netowrk that when trained on a peice of text and fed a starting prompt will write its on 250 character text using LSTM layers

RNN-Playwrite a reccurrent neural netowrk that when trained on a peice of text and fed a starting prompt will write its on 250 character text using LS

Using LSTM write Tang poetry
Using LSTM write Tang poetry

本教程将通过一个示例对LSTM进行介绍。通过搭建训练LSTM网络,我们将训练一个模型来生成唐诗。本文将对该实现进行详尽的解释,并阐明此模型的工作方式和原因。并不需要过多专业知识,但是可能需要新手花一些时间来理解的模型训练的实际情况。为了节省时间,请尽量选择GPU进行训练。

A framework that allows people to write their own Rocket League bots.
A framework that allows people to write their own Rocket League bots.

YOU PROBABLY SHOULDN'T PULL THIS REPO Bot Makers Read This! If you just want to make a bot, you don't need to be here. Instead, start with one of thes

This project uses reinforcement learning on stock market and agent tries to learn trading. The goal is to check if the agent can learn to read tape. The project is dedicated to hero in life great Jesse Livermore.

Reinforcement-trading This project uses Reinforcement learning on stock market and agent tries to learn trading. The goal is to check if the agent can

Designing a Minimal Retrieve-and-Read System for Open-Domain Question Answering (NAACL 2021)
Designing a Minimal Retrieve-and-Read System for Open-Domain Question Answering (NAACL 2021)

Designing a Minimal Retrieve-and-Read System for Open-Domain Question Answering Abstract In open-domain question answering (QA), retrieve-and-read mec

Read Like Humans: Autonomous, Bidirectional and Iterative Language Modeling for Scene Text Recognition
Read Like Humans: Autonomous, Bidirectional and Iterative Language Modeling for Scene Text Recognition

Read Like Humans: Autonomous, Bidirectional and Iterative Language Modeling for Scene Text Recognition The official code of ABINet (CVPR 2021, Oral).

Allele-specific pipeline for unbiased read mapping(WIP), QTL discovery(WIP), and allelic-imbalance analysis

WASP2 (Currently in pre-development): Allele-specific pipeline for unbiased read mapping(WIP), QTL discovery(WIP), and allelic-imbalance analysis Requ

Prompts - Read a textfile of prompts and import into anki via ankiconnect

prompts read a textfile of prompts and import into anki via ankiconnect Usage In

Comments
  • can output tif keep layers ?

    can output tif keep layers ?

    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()],
    )
    
    
    question 
    opened by jindili 4
  • write .tif to be read with photoshop

    write .tif to be read with photoshop

    Is it possible to put multiple images, as layers, into a tif file and have them be read by photoshop.

    I tried the following,

    with tifffile.TiffWriter('temp.tif') as tiff:
        for img in data:
            data_block = bytes('Adobe Photoshop Document Data Block', 'ascii') + b'\x00'
            bim = bytes('8BIM', 'ascii')
            layer = bytes('Layr', 'ascii')
            img_bytes = img.tobytes()
            img_len = len(img_bytes)
            img_len_bytes = bytes(str(img_len), 'ascii')
            all_bytes = data_block + bim + layer + img_len_bytes
            byte_length = len(all_bytes) - len(data_block)
            bytes_bytes = bytes(byte_length)
            allll = all_bytes + bytes_bytes
            metad = {"37724": str(allll)}
            
            tiff.save(img, metadata=metad)
    tif.close()
    

    which works with preview (on mac) but not photoshop. Photoshop only sees the first layer...

    opened by StefanBaar 2
  • Create multi-layered tiff from png images

    Create multi-layered tiff from png images

    Hi @cgohlke. First of all, awesome work! I got your library from stackoverflow that it might be helpful for me. What I need is to create a multi-layered tiff. Just the same like you exported tiff from your photoshop.

    Here is an example of files: google drive where you have photoshop file and tif created from it and also images which was created from.

    This I want to accomplish, when you open generated tif, photoshop needs to see as layers. e4542

    I tried multiple approach:

    • generate psd and then with imagemagic convert to tif but without a success.
    • generate a tif with wand library
    • generate psd and convert with online tools ... and I'm complete stuck.

    here is the stackoverflow

    question 
    opened by konri 1
Owner
Christoph Gohlke
Christoph Gohlke
Code for "Layered Neural Rendering for Retiming People in Video."

Layered Neural Rendering in PyTorch This repository contains training code for the examples in the SIGGRAPH Asia 2020 paper "Layered Neural Rendering

Google 154 Dec 16, 2022
Code for "Unsupervised Layered Image Decomposition into Object Prototypes" paper

DTI-Sprites Pytorch implementation of "Unsupervised Layered Image Decomposition into Object Prototypes" paper Check out our paper and webpage for deta

null 40 Dec 22, 2022
PyTorch implementations for our SIGGRAPH 2021 paper: Editable Free-viewpoint Video Using a Layered Neural Representation.

st-nerf We provide PyTorch implementations for our paper: Editable Free-viewpoint Video Using a Layered Neural Representation SIGGRAPH 2021 Jiakai Zha

Diplodocus 258 Jan 2, 2023
Layered Neural Atlases for Consistent Video Editing

Layered Neural Atlases for Consistent Video Editing Project Page | Paper This repository contains an implementation for the SIGGRAPH Asia 2021 paper L

Yoni Kasten 353 Dec 27, 2022
Knowledge Management for Humans using Machine Learning & Tags

HyperTag HyperTag helps humans intuitively express how they think about their files using tags and machine learning.

Ravn Tech, Inc. 165 Nov 4, 2022
This tool uses Deep Learning to help you draw and write with your hand and webcam.

This tool uses Deep Learning to help you draw and write with your hand and webcam. A Deep Learning model is used to try to predict whether you want to have 'pencil up' or 'pencil down'.

lmagne 169 Dec 10, 2022
Ludwig is a toolbox that allows to train and evaluate deep learning models without the need to write code.

Translated in ???? Korean/ Ludwig is a toolbox that allows users to train and test deep learning models without the need to write code. It is built on

Ludwig 8.7k Jan 5, 2023
Ludwig is a toolbox that allows to train and evaluate deep learning models without the need to write code.

Translated in ???? Korean/ Ludwig is a toolbox that allows users to train and test deep learning models without the need to write code. It is built on

Ludwig 8.7k Dec 31, 2022