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

Field 'layers' has not been initialized. #692

Open
TheCGDF opened this issue Nov 8, 2024 · 4 comments
Open

Field 'layers' has not been initialized. #692

TheCGDF opened this issue Nov 8, 2024 · 4 comments

Comments

@TheCGDF
Copy link

TheCGDF commented Nov 8, 2024

psd = image.PsdImage(picked.files.first.bytes!);
print(psd!.isValid);
print(psd!.layers.length);

I have tried many psd files but always this error:

flutter: true
[ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: LateInitializationError: Field 'layers' has not been initialized.
#0      PsdImage.layers (package:image/src/formats/psd/psd_image.dart)
#1      _MyHomePageState.build.<anonymous closure>.<anonymous closure> (package:psd_separator/main.dart:57:30)
#2      State.setState (package:flutter/src/widgets/framework.dart:1203:30)
#3      _MyHomePageState.build.<anonymous closure> (package:psd_separator/main.dart:54:17)
<asynchronous suspension>
@brendan-duncan
Copy link
Owner

I have all of the internal PSD loading stuff commented out because it was always experimental and there were some problematic PSD files. Is there a reason you're wanting to access the PSD internal info and not just the final composited image?

@brendan-duncan
Copy link
Owner

I re-added the internal PSD structure decoding code. The decoder does not use that info for the resulting image, PSD stores a final composited version of the image within the file that is used by the decoder. The layer and other PSD stuff is really just there for general "this is interesting" info.

@TheCGDF
Copy link
Author

TheCGDF commented Nov 10, 2024

Is there a reason you're wanting to access the PSD internal info and not just the final composited image?

I'm developing a tool to separate all PSD layers into PNGs. It's quite troublesome to make it by hand. I'm not sure if it can be a reason...

@brendan-duncan
Copy link
Owner

You can try it out with the git version, see if it does what you need now. But beyond what's there I probably won't be adding too much more to it.

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

2 participants