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

Warning: Unknown tagged block iOpa #15

Closed
jenil opened this issue Nov 26, 2013 · 15 comments
Closed

Warning: Unknown tagged block iOpa #15

jenil opened this issue Nov 26, 2013 · 15 comments

Comments

@jenil
Copy link

jenil commented Nov 26, 2013

Hello,

I am getting this warning. Please help.

Warning (from warnings module):
  File "/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/site-packages/psd_tools/decoder/tagged_blocks.py", line 51
    warnings.warn("Unknown tagged block (%s)" % block.key)
UserWarning: Unknown tagged block (b'iOpa')
@kmike
Copy link
Member

kmike commented Nov 26, 2013

Hi @jenil27,

psd-tools doesn't know what is 'iOpa' tagged block; it is not documented in Adobe specs and I haven't seen it elsewhere when the code was written.

I think you could ignore this warning. It shouldn't be a warning though, because user of the library can do nothing about it. I'm not closing this ticket because it shouldn't be a warning, and because it is better to figure out what does this block mean and how to decode it (most likely by looking at alternative psd reader implementations).

@jenil
Copy link
Author

jenil commented Nov 26, 2013

hey @kmike thanks for your reply. It is a Adobe specs file, I am sure. I am not sure what is meant by a tagged block could you help me with that?
Also, This is my code

from psd_tools import PSDImage

psd = PSDImage.load('/Users/jenil/mock.psd')
bg = psd.layers[0].layers[1]
print(bg)
print(bg.as_PIL())

it get an error:

<psd_tools.Layer: 'Hand', size=1971x1294, x=-20, y=3>
Traceback (most recent call last):
  File "/Users/jenil/Downloads/psdpy.py", line 6, in <module>
    print(bg.as_PIL())
  File "/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/site-packages/psd_tools/user_api/psd_image.py", line 91, in as_PIL
    return self._psd._layer_as_PIL(self._index)
  File "/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/site-packages/psd_tools/user_api/psd_image.py", line 243, in _layer_as_PIL
    return pil_support.extract_layer_image(self.decoded_data, index)
  File "/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/site-packages/psd_tools/user_api/pil_support.py", line 32, in extract_layer_image
    decoded_data.header.depth, get_icc_profile(decoded_data))
  File "/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/site-packages/psd_tools/user_api/pil_support.py", line 68, in _channels_data_to_PIL
    raise Exception("This module requires PIL (or Pillow) installed.")
Exception: This module requires PIL (or Pillow) installed.

I have installed Pillow and it works fine.
Any help would be appreciated.

@kmike
Copy link
Member

kmike commented Nov 26, 2013

@jenil27 I don't follow: you said the code works fine, what help do you need? It is documented in both README and in exception message itself that you need PIL or Pillow; PIL/Pillow is an optional dependency and some parts of psd-tools can be used without them.

Specification I'm talking about is http://www.adobe.com/devnet-apps/photoshop/fileformatashtml/ ; it doesn't have information about iOpa constant. Most likely Adobe added it without updating the specs.

@jenil
Copy link
Author

jenil commented Nov 27, 2013

@kmike Why am I getting an error when i do print(bg.as_PIL())?

@kmike
Copy link
Member

kmike commented Nov 27, 2013

@jenil27 sorry, I read your question incorrectly.
The code that fails is the following:

try:
    from PIL import Image, ImageCms
    if hasattr(Image, 'frombytes'):
        frombytes = Image.frombytes
    else:
        frombytes = Image.fromstring

except ImportError:
    Image = None

If Image is None you get "This module requires PIL (or Pillow)" exception. Could you try running it in the same console/environment as print(bg.as_PIL()) ?

@jenil
Copy link
Author

jenil commented Nov 27, 2013

How can I resolve it?

@kmike
Copy link
Member

kmike commented Nov 27, 2013

Does from PIL import Image, ImageCms raise an exception if you run it after print(bg.as_PIL())? If so it means that Pillow is not installed correctly (e.g. maybe you've installed it to another environment).

@jenil
Copy link
Author

jenil commented Nov 27, 2013

Okay, I got this error

Traceback (most recent call last):
  File "/Users/jenil/Downloads/psdpy.py", line 6, in <module>
    from PIL import Image, ImageCms
  File "/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/site-packages/Pillow-2.0.0-py3.3-macosx-10.6-intel.egg/PIL/ImageCms.py", line 85, in <module>
    import _imagingcms
ImportError: No module named '_imagingcms'

@kmike
Copy link
Member

kmike commented Nov 27, 2013

Ah, I see. This could mean Pillow is installed without LittleCMS support. LittleCMS is required to get correct colors for some images, and it turns out it is not optional at the moment.

So there are 2 ways to resolve that:

  1. Make LittleCMS optional by changing the conditional import and not using ImageCms if it is not available; a PR is welcome :)
  2. make sure Pillow is installed with LittleCMS support.

@jenil
Copy link
Author

jenil commented Nov 27, 2013

@kmike
Copy link
Member

kmike commented Nov 27, 2013

Yep, the exception message was unhelpful.

@jenil
Copy link
Author

jenil commented Nov 27, 2013

Installed LittleCMS and reinstalled Pillow made it work! Cheers!

@jenil jenil closed this as completed Nov 27, 2013
@kmike
Copy link
Member

kmike commented Nov 27, 2013

I'll reopen it to track the original bug report about 'iOpa' unknown tagged block.

@kmike kmike reopened this Nov 27, 2013
@GaborWnuk
Copy link

Hello @kmike,

recently i've tried to open PSD from Photoshop CC and got following warnings:

/Users/.../.env/lib/python2.7/site-packages/psd_tools/decoder/tagged_blocks.py:57: UserWarning: Unknown tagged block (iOpa)
  warnings.warn("Unknown tagged block (%s)" % block.key)
/Users/.../.env/lib/python2.7/site-packages/psd_tools/decoder/tagged_blocks.py:57: UserWarning: Unknown tagged block (vstk)
  warnings.warn("Unknown tagged block (%s)" % block.key)
/Users/.../.env/lib/python2.7/site-packages/psd_tools/decoder/tagged_blocks.py:57: UserWarning: Unknown tagged block (lnkE)
  warnings.warn("Unknown tagged block (%s)" % block.key)
/Users/.../.env/lib/python2.7/site-packages/psd_tools/user_api/pil_support.py:203: UserWarning: Channel -2 (USER_LAYER_MASK) is not handled
  warnings.warn("Channel %s (%s) is not handled" % (channel_id, ChannelID.name_of(channel_id)))
/Users/.../.env/lib/python2.7/site-packages/psd_tools/user_api/pil_support.py:153: UserWarning: Unsupported channel type (-2)
  warnings.warn("Unsupported channel type (%d)" % channel_id)

After re-saving in Photoshop CS5, only following error left:

/Users/.../.env/lib/python2.7/site-packages/psd_tools/decoder/tagged_blocks.py:57: UserWarning: Unknown tagged block (iOpa)
  warnings.warn("Unknown tagged block (%s)" % block.key)

However, all my layers with effects on them (in my case - color overlay effect) are rendered like those effects are nonexistent / disabled (layer / group is still saved, but colour overlay effect is ignored).

@kmike
Copy link
Member

kmike commented Jul 3, 2014

Hi @GaborWnuk,

Would it be possible for you to provide a small example PSD file for which psd-tools shows the described warnings so that we can add it to the testing suite?

Do you export layer groups? Currently this feature is experimental, and it produces the precise result only in simple cases - alpha transparency is supported, but nothing more. Effects information is parsed since psd-tools 0.10, but applying the effects is an another (harder) task - to make it work we should emulate Photoshop rendering features. I hope psd-tools will eventually get this feature, but it won't happen overnight; any help is welcome.

Exporting the whole image and exporting individual layers should work much better because for individual layers and for the whole image there are bitmaps prerendered by Photoshop available. There are no prerendered bitmaps for layer groups - that's why layer groups rendering is much more involved.

"Unknown tagged block" warnings should be harmless, you may ignore it unless you need information from these blocks for some reason. If you have some ideas about what these blocks are - please share them!

"Unsupported channel type" warning means psd-tools doesn't know how to deal with a particular kind of image channel. I may be mistaken, but it seems user layer mask don't affect rendering of the final image, so this warning may also be ignored.

@kyamagu kyamagu closed this as completed Feb 20, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants