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

Issue with ag-psd modifying PSD file leading to ArgumentOutOfRangeException when loaded with Aspose.PSD #146

Open
w0fv1 opened this issue Jul 20, 2023 · 5 comments
Assignees

Comments

@w0fv1
Copy link

w0fv1 commented Jul 20, 2023

I am having a problem with handling PSD files in my project. I use the ag-psd library on the frontend to read and write PSD files. Then I upload the resulting file to a backend service that uses Aspose.PSD for Java to load and process these files.

However, when Aspose.PSD tries to load the uploaded file, it throws an exception with the following error message:

com.aspose.psd.internal.Exceptions.ArgumentOutOfRangeException: Specified argument was out of the range of valid values.
Parameter name: startPosition

This is the code I use on the frontend:


const files = event.target.files;
if (files.length > 0) {
  const file = files[0];
  const arrayBuffer = await file.arrayBuffer();
  const psd = readPsd(arrayBuffer);

  const imageData = writePsd(readPsd(arrayBuffer));
  const blob = new Blob([imageData], { type: 'application/octet-stream' });
  let formData = new FormData();
  formData.append('psd_file', blob, file.name);

  try {
    const response = await fetch('http://localhost:24568/psd_template', {
      method: 'POST',
      body: formData
    });
    if (response.ok) {
      console.log('Upload successful');
      console.log(response);
    } else {
      console.error('Upload failed with HTTP status', response.status);
    }
  } catch (error) {
    console.error('Upload failed with error', error);
  }
}

And this is the code on the backend:

PsdImage image = (PsdImage) Image.load(saveFile.getPath());
Could you please help me to understand if the ag-psd library is modifying the PSD file format in some way? Is there anything I can do to fix or work around this problem?

I will relay the responses from Aspose.PSD here in real time.

I'm not sure if the problem lies with ag-psd or aspose.psd.

Do you have any thoughts on this issue?

Best regards

@Agamnentzar Agamnentzar self-assigned this Jul 20, 2023
@Agamnentzar
Copy link
Owner

Can you check if the output PSD file is opening correctly in Photoshop? Can you share the output and input PSD files?

@w0fv1
Copy link
Author

w0fv1 commented Jul 21, 2023

psd.zip

It can be opened normally in Photoshop.

@w0fv1
Copy link
Author

w0fv1 commented Jul 22, 2023

@Agamnentzar
The developer of aspose.psd has replied with the following response, which may help to fix the issue.

Dmitriy.Sorokin
约 21 小时
@wofbi We’ve made investigation. This issue is reproducable both Aspose.PSD for .Net and Aspose.PSD for Java, so, I created task PSDJAVA-458: File changed in the 3rd party library corrupts PSD file but it can be opened in the Photoshop. We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.
ETA: it will be fixed in Aspose.PSD 23.8 for .Net, so it will be fixed in Aspose.PSD for Java in September.
You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.

It happens all the time that two independently implemented libraries are incompatible with each other, and I don't think ag-psd corrupts psd files.
But aspose.psd is improving compatibility, which should be a good thing.

@Agamnentzar
Copy link
Owner

I fixed 2 different issues with reading and writing in version 17.0.1

That could possibly cause the issue, let me know if it helped.

@krishankanhaya
Copy link

ag-psd lib can read and modify text? then how to save it in nodejs for text is in nested layer. please gave code sample that is really helpfull for me.

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

3 participants