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

Can't find variable: Buffer #114

Open
Florent75 opened this issue Jan 25, 2024 · 0 comments
Open

Can't find variable: Buffer #114

Florent75 opened this issue Jan 25, 2024 · 0 comments

Comments

@Florent75
Copy link

Hi there,

I have been using the jpeg-js module with an iOS application and everything was working correctly
Now I have passed to an android version of the same App.
But there is an issue that I don't get.

When I use the decode function i have the following error : Can't find variable: Buffer
After checking it's at line 1128 of the jpeg-js module.

try {
JpegImage.requestMemoryAllocation(bytesNeeded);
var image = {
width: decoder.width,
height: decoder.height,
exifBuffer: decoder.exifBuffer,
data: opts.useTArray ?
new Uint8Array(bytesNeeded) :
Buffer.alloc(bytesNeeded)
};
if(decoder.comments.length > 0) {
image["comments"] = decoder.comments;
}
} catch (err) {
if (err instanceof RangeError) {
throw new Error("Could not allocate enough memory for the image. " +
"Required: " + bytesNeeded);
}

if (err instanceof ReferenceError) {
  if (err.message === "Buffer is not defined") {
    throw new Error("Buffer is not globally defined in this environment. " +
                    "Consider setting useTArray to true");
  }
}
throw err;

}

I don't get why the Buffer is not a global variable ?

Package.json data :
"react": "18.2.0",
"react-native": "0.71.0",
"buffer": "^6.0.3",
"jpeg-js": "^0.4.4",

Do you have any clues on this ?

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

1 participant