Jump to content
Daniel Schmidt

[By Design] PSB file import bug - The file could not be parsed: unknown signature

Recommended Posts

I have trouble with import of PSB files created by my own custom software. The files all open fine in Photoshop (CS4, CC2017) but some not in Affinity.

I tested a lot of things but can't verify what Affinity complains about, since the error message is not helpful. So I have come up with a super small image so you can check this easily. The test file is less then 500 bytes in size. There are no custom data chunks in the file. The same file as 16-bits per channel opens fine and also when resaved in Photoshop (also attached).

 

File: PSBtest_8bit_BUG.psb  PSB, 1x1 px, 8bit, 1 layer "Diffuse", uncompressed (RAW)

Fails in: 1.6.0.82 Beta and 1.5.2.69 (did not test further versions)

 

affinity_psb_import_error.JPG.fa7d06c9f002a4429b4050574809884e.JPG

 

Please have a look and let me know if you need more example files or technical details. It might be helpful for other developers like me if Affinity reported the exact file location in such error messages.

 

Best Regards,

Daniel

 

PSBtest_8bit_resavedbyPhotoshopOK.psb

PSBtest_16bit_resavedbyPhotoshopOK.psb

PSBtest_16bitOK.psb

PSBtest_8bit_BUG.psb

Share this post


Link to post
Share on other sites
7 hours ago, Daniel Schmidt said:

Thanks, I wasn't sure where to post bugs occuring in beta and customer version.

 

If a bug occurs in a beta version but not in the release version, then it has been newly introduced in the beta and it should therefore be reported in the beta forum. If it occurs in both versions, then it's a bug in the release version that hasn't been fixed, so it should be reported in the general bugs forum.


Alfred online2long.gif
Affinity Designer/Photo/Publisher for Windows • Windows 10 Home (4th gen Core i3 CPU)
Affinity Photo for iPad 1.8.6 • Designer for iPad 1.8.6 • iPadOS 14.2 (iPad Air 2)

Share this post


Link to post
Share on other sites

I've looked at the PSBtest_8bit_BUG.psb file.  It is badly formed.

 

It looks like you are writing the Global Layer Mask Info length as 8-bytes, whereas the specification says it should still be 4-bytes, even for PSB format - it's one of the few sections that doesn't write it's size as 8-bytes for PSB.  It doesn't appear you are making the same mistake when writing out the 16-bit version of the file.

 

The section size should also be 0 or rounded up to 16 bytes (multiple of 4).  You are storing a section size of 14 (rounded to multiple of 2). The specification shows the structure should be 13 bytes, rounded up to 16 with packing.

 

Photoshop is being lenient in letting you open this file - hence why you can resave it. The file it saves out again then corrects your errors.

 

We won't be fixing anything our end because we are following the spec.

 


SerifLabs team - Affinity Developer
  • Software engineer  -  Photographer  -  Guitarist  -  Philosopher
  • iMac 27" Retina 5K (Late 2015), 4.0GHz i7, AMD Radeon R9 M395
  • MacBook (Early 2015), 1.3GHz Core M, Intel HD 5300
  • iPad Pro 10.5", 256GB

Share this post


Link to post
Share on other sites

We also won't be adding any diagnostic tools to help other developers debug their PSD/PSB files.  We have spent considerable time ensuring that we follow the specification, allowing for certain errors in PSD files from other common vendors.  Reporting an exact file location is subjective because the error that causes the misalignment might occur earlier in the file.  I had to work out the actual error through debugging.

 

You can assume that if a file fails to open in Affinity and it reports a bad signature or a misalignment, then the file is badly formed. (Especially true if the file can be opened if you save it out again from Photoshop).

 


SerifLabs team - Affinity Developer
  • Software engineer  -  Photographer  -  Guitarist  -  Philosopher
  • iMac 27" Retina 5K (Late 2015), 4.0GHz i7, AMD Radeon R9 M395
  • MacBook (Early 2015), 1.3GHz Core M, Intel HD 5300
  • iPad Pro 10.5", 256GB

Share this post


Link to post
Share on other sites

Thanks for raising this issue - we have closed it as "by design".


SerifLabs team - Affinity Developer
  • Software engineer  -  Photographer  -  Guitarist  -  Philosopher
  • iMac 27" Retina 5K (Late 2015), 4.0GHz i7, AMD Radeon R9 M395
  • MacBook (Early 2015), 1.3GHz Core M, Intel HD 5300
  • iPad Pro 10.5", 256GB

Share this post


Link to post
Share on other sites

Just one bit of advice - if you are writing your own PSD reader/writer and have similar problems - you need to compare how Photoshop has written your file and work out the differences.  Starting with a small file will help.  That can validate your assumptions of how each struct is formed, and what values to expect.  We found out that the documentation has some areas that could be better explained, and comparing the doc against an actual file can help resolve that.


SerifLabs team - Affinity Developer
  • Software engineer  -  Photographer  -  Guitarist  -  Philosopher
  • iMac 27" Retina 5K (Late 2015), 4.0GHz i7, AMD Radeon R9 M395
  • MacBook (Early 2015), 1.3GHz Core M, Intel HD 5300
  • iPad Pro 10.5", 256GB

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...

Important Information

Please note the Annual Company Closure section in the Terms of Use. These are the Terms of Use you will be asked to agree to if you join the forum. | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.