psd-tools / psd-tools

Python package for reading Adobe Photoshop PSD files
https://psd-tools.readthedocs.io/
MIT License
1.15k stars 191 forks source link

Unknown image resource 1092 #324

Closed megaz0rd closed 2 years ago

megaz0rd commented 2 years ago

Hi,

Tech stack: python 3.10.2 Django 3.2.7 psdtools ^1.9.21

Im using PSDImage in the script to generate wall mockups for our product. I keep cached psd images locally after downloading them from the cloud. psd = PSDImage.open(PosixPath('filename.psd')) It works fine but sometimes prints a msg: Unknown image resource 1092 and still returns an instance e.g.: PSDImage(mode=ColorMode.RGB size=2048x2048 depth=8 channels=4) [0] PixelLayer('back' size=2048x2048) [1] PixelLayer('front' size=2048x2048) I can't find anything about this error.

psd.image_resources returns: { IPTC_NAA: b'\x1c\x01Z\x00\x03\x1b%G\x1c\x02\x00\x00\x02\x00\x00', CAPTION_DIGEST: b'\xcd\xcf\xfa}\xa8\xc7\xbe\t\x05pv\xae\xaf\x05\xc3N', XMP_METADATA: b'<?xpacket begin= ... =15782', PRINT_INFO_CS5: DescriptorBlock(b'printOutput'){ 'PstS': True, 'Inte': (b'Inte', b'Clrm'), 'printSixteenBit': False, 'printerName': '\x00', 'printProofSetup': Descriptor(b'proofSetup'){ 'Bltn': (b'builtinProof', b'proofCMYK') } }, PRINT_STYLE: DescriptorBlock(b'printOutputOptions'){ 'Cptn': False, 'Clbr': False, 'RgsM': False, 'CrnC': False, 'CntC': False, 'Lbls': False, 'Ngtv': False, 'EmlD': False, 'Intr': False, 'Bckg': Descriptor(b'RGBC'){'Rd ': 255.0, 'Grn ': 255.0, 'Bl ': 255.0}, 'BrdT': 0.0 Distance, 'Bld ': 0.0 Distance, 'Rslt': 72.0 Pixels, 'vectorData': True, 'PgPs': (b'PgPs', b'PgPC'), 'Left': 0.0 Distance, 'Top ': 0.0 Distance, 'Scl ': 100.0 Percent, 'cropWhenPrinting': False, 'cropRectBottom': 0, 'cropRectLeft': 0, 'cropRectRight': 0, 'cropRectTop': 0 }, RESOLUTION_INFO: ResoulutionInfo( horizontal=4718592, horizontal_unit=1, width_unit=2, vertical=4718592, vertical_unit=1, height_unit=2 ), PRINT_SCALE: PrintScale(style=CENTERED, x=0.0, y=0.0, scale=1.0), ALPHA_NAMES_PASCAL: ['PrzezroczystoÊç'], ALPHA_NAMES_UNICODE: ['Przezroczystość\x00'], DISPLAY_INFO: b'\x00\x00\x00\x01\x00\x00\xff\xff\x00\x00\x00\x00\x00\x00\x00d ... =17', ALPHA_IDENTIFIERS: [0], GLOBAL_ANGLE: 30, GLOBAL_ALTITUDE: 30, PRINT_FLAGS: PrintFlags( labels=False, crop_marks=False, colorbars=False, registration_marks=False, negative=False, flip=False, interpolate=False, caption=False, print_flags=True ), PRINT_FLAGS_INFO: PrintFlagsInfo( version=1, center_crop=0, bleed_width_value=0, bleed_width_scale=2 ), COLOR_HALFTONING_INFO: [ HalftoneScreen( freq=47.399993896484375, unit=1, angle=108.39999389648438, shape=6, use_accurate=False, use_printer=True ), HalftoneScreen( freq=47.399993896484375, unit=1, angle=161.60000610351562, shape=6, use_accurate=False, use_printer=True ), HalftoneScreen( freq=50.0, unit=1, angle=90.0, shape=6, use_accurate=False, use_printer=True ), HalftoneScreen( freq=53.0, unit=1, angle=45.0, shape=6, use_accurate=False, use_printer=True ) ], COLOR_TRANSFER_FUNCTION: [ TransferFunction( curve=[0, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 1000], override=0 ), TransferFunction( curve=[0, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 1000], override=0 ), TransferFunction( curve=[0, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 1000], override=0 ), TransferFunction( curve=[0, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 1000], override=0 ) ], LAYER_STATE_INFO: 0, LAYER_GROUP_INFO: [0, 0], LAYER_GROUPS_ENABLED_ID: [1, 1], LAYER_SELECTION_IDS: [2], GRID_AND_GUIDES_INFO: GridGuidesInfo( version=1, horizontal=576, vertical=576, data=[] ), 1092: b'\x00\x00\x00\x02\x00\x00\x02@\x00\x00\x02@\x00\x00\x00\x00', URL_LIST: [], SLICES: Slices( version=6, data=SlicesV6( bbox=[0, 0, 2048, 2048], name='living-room-beazy-glamor', items=[SliceV6( slice_id=0, group_id=0, origin=0, associated_id=None, name='', slice_type=1, bbox=[0, 0, 2048, 2048], url='', target='', message='', alt_tag='', cell_is_html=True, cell_text='', horizontal_align=0, vertical_align=0, alpha=0, red=0, green=0, blue=0, data=DescriptorBlock(b'null'){ 'bounds': Descriptor(b'Rct1'){ 'Top ': 0, 'Left': 0, 'Btom': 2048, 'Rght': 2048 }, 'slices': [ Descriptor(b'slice'){ 'sliceID': 0, 'groupID': 0, 'origin': (b'ESliceOrigin', b'autoGenerated'), 'Type': (b'ESliceType', b'Img '), 'bounds': Descriptor(b'Rct1'){ 'Top ': 0, 'Left': 0, 'Btom': 2048, 'Rght': 2048 }, 'url': '\x00', 'null': '\x00', 'Msge': '\x00', 'altTag': '\x00', 'cellTextIsHTML': True, 'cellText': '\x00', 'horzAlign': (b'ESliceHorzAlign', b'default'), 'vertAlign': (b'ESliceVertAlign', b'default'), 'bgColorType': (b'ESliceBGColorType', b'None'), 'topOutset': 0, 'leftOutset': 0, 'bottomOutset': 0, 'rightOutset': 0 } ] } )] ) ), PIXEL_ASPECT_RATIO: 1.0, ICC_PROFILE: b'\x00\x00\x02\x0clcms\x02\x10\x00\x00mntr ... =524', IDS_SEED_NUMBER: 9, THUMBNAIL_RESOURCE: ThumbnailResource( fmt=1, width=160, height=160, row=480, total_size=76800, bits=24, planes=1, data=b'\xff\xd8\xff\xed\x00\x0cAdobe_CM\x00\x01 ... =4773' ), VERSION_INFO: VersionInfo( version=1, has_composite=True, writer='Adobe Photoshop', reader='Adobe Photoshop 2022', file_version=1 ), EXIF_DATA_1: b'MM\x00*\x00\x00\x00\x08\x00\x0c\x01\x00\x00\x03\x00\x00 ... =386' }

At the end - I have proper rendered mockup even if this msg was printed.

Any suggestions?

kyamagu commented 2 years ago

No worry, this warning just states there is an unknown data in the image resource section of the PSD file, perhaps from plugins or a specific version of Photoshop.

megaz0rd commented 2 years ago

thanks, I've figured it out. It was about sth with nested color profile. I've saved psd without it and warning has disappeard.