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

Adding watermark for different size images error #5

Open
Zevcoresuhas opened this issue Oct 27, 2022 · 12 comments
Open

Adding watermark for different size images error #5

Zevcoresuhas opened this issue Oct 27, 2022 · 12 comments
Labels
bug Something isn't working enhancement New feature or request good first issue Good for newcomers

Comments

@Zevcoresuhas
Copy link

Zevcoresuhas commented Oct 27, 2022

Error: Image to composite must have same dimensions or smaller
when this error appear image not saving

If i add watermark image with lesser px size than uploading image px size it will upload correct and add watermark or image size px size les than watermark px size i get this error

ex:

  1. Upload image px size 600x600 . Watermark image px size 600x600 Working good
  2. Upload image px size 600x600 . Watermark image px size 1000x800 Not working

Please help

@ranjandsingh ranjandsingh added the bug Something isn't working label Oct 27, 2022
@ranjandsingh
Copy link
Owner

ranjandsingh commented Oct 27, 2022

Hey Can you explain a little more I mean are you defining size
(Upload image px size 1000x800 . Watermark image px size 600x600 Not working)

@Zevcoresuhas
Copy link
Author

Hey Can you explain a little more I mean are you difinig size

Yes

const storage = SharpMulter({
destination: (req, file, callback) => {
callback(null, "./public/photo");
},

imageOptions: {
fileFormat: "jpg",
useTimestamp: true,
quality: 40,
resize: { width: 600, height: 600, resizeMode: "outside" },
},
watermarkOptions: {
input: "./public/photo/logo.png", // watermark image location
location: "center",
},
});

@ranjandsingh
Copy link
Owner

I'm loooking into it Let me clear this one up with this config you are uploading two sizes 600X600 that's uploads successfully but 1000X800 fails to upload correct ?

@Zevcoresuhas
Copy link
Author

Hey Can you explain a little more I mean are you defining size (Upload image px size 1000x800 . Watermark image px size 600x600 Not working)
I update my question sorry

@Zevcoresuhas
Copy link
Author

I'm loooking into it Let me clear this one up with this config you are uploading two sizes 600X600 that's uploads successfully but 1000X800 fails to upload correct ?

Error while water image greater than upload image it gives me this error

@ranjandsingh
Copy link
Owner

This is a limitation of sharp itself you can't put a bigger image on top of a smaller image as a watermark.

@ranjandsingh
Copy link
Owner

This is a limitation of sharp itself you can't put a bigger image on top of a smaller image as a watermark.

Best thing we can do is check if watermark is bigger than uploading image resize before putting it on as a watermark

@Zevcoresuhas
Copy link
Author

This is a limitation of sharp itself you can't put a bigger image on top of a smaller image as a watermark.

Can water image resize according to upload image because we cant tell which image they can add

@Zevcoresuhas
Copy link
Author

Zevcoresuhas commented Oct 27, 2022

How can we do that
Using image-size

@ranjandsingh
Copy link
Owner

ranjandsingh commented Oct 27, 2022

For now just resize you image manually I'll add this functionality in the package itself in couple days

@Zevcoresuhas
Copy link
Author

Thank you so much for your replies. I will be waiting for update.

@ranjandsingh
Copy link
Owner

Thank you for using it and making it better.

@ranjandsingh ranjandsingh added enhancement New feature or request good first issue Good for newcomers labels Nov 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

When branches are created from issues, their pull requests are automatically linked.

2 participants