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

How to use this for image which is being fetched from online source, I am not looking for saving the file on disk before rotating. #36

Closed
abhinovpankaj opened this issue Sep 28, 2023 · 1 comment

Comments

@abhinovpankaj
Copy link

How to use this for image which is being fetched from online source, I am not looking for saving the file on disk before rotating.

@abhinovpankaj
Copy link
Author

Written below code
try {
const resp = await fetch(
imageurl
);
if (resp.ok) {
const imagebuffer = resp.arrayBuffer
? await resp.arrayBuffer()
: await resp.buffer();
const extension = path.extname(imageurl);
//fix image rotation
try {
var {buffer} = await jo.rotate(Buffer.from(imagebuffer), {quality:50});

            return { height: 6.2,width: 4.85,  data: buffer, extension: extension };
          } catch (error) {
            console.log('An error occurred when rotating the file: ' + error);
            return { height: 6.2,width: 4.85,  data: imagebuffer, extension: extension };
          }
        }else{
          return;
        }
      } catch (error) {
        console.log(error);
        return ;
      }   

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