Mikhail Korobov  committed 97f226b

some tweaks

  • Participants
  • Parent commits bffd16a
  • Branches default

Comments (0)

Files changed (4)

 I also considered contributing to pypsd or psdparse, but they are
 GPL and I was not totally satisfied with the interface and the code
-(they are really fine, it's me having specific style requirements).
+(they are really fine, that's me having specific style requirements).
 So I finally decided to roll out yet another implementation
 that should be MIT-licensed, systematically based on the specification_

File psd_tools/

         -v --verbose                Be more verbose.
-        --encoding <encoding>       Text encoding [default: latin1].
+        --encoding <encoding>       Text encoding [default: ascii].
     args = docopt.docopt(main.__doc__)

File psd_tools/

     PRINT_FLAGS_INFO = 10000
+    @classmethod
+    def is_known(cls, value):
+        path_info = cls.PATH_INFO_FIRST <= value <= cls.PATH_INFO_LAST
+        plugin_resource = cls.PLUGIN_RESOURCES_FIRST <= value <= cls.PLUGIN_RESOURCES_LAST
+        return super(ImageResourceID, cls).is_known(value) or path_info or plugin_resource
 class BlendMode(Enum):
     PASS_THROUGH = 'pass'
     NORMAL = 'norm'

File psd_tools/decoder/

     return [parse_image_resource(res) for res in image_resource_blocks]
 def parse_image_resource(resource):
+    if not ImageResourceID.is_known(resource.resource_id):
+        warnings.warn("Unknown resource_id (%s)" % resource.resource_id)
     decoder = _image_resource_decoders.get(resource.resource_id, lambda data: data)
     return resource._replace(data = decoder(
     ImageResourceID.ALPHA_NAMES_UNICODE: _unicode_decoder,
     ImageResourceID.WORKFLOW_URL: _unicode_decoder,
 def register(resource_id):