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

If an image is small and the other image is big, the background color behind small image is not getting set to white or transparent. #1

Open
abdulwajid725 opened this issue Jan 17, 2018 · 13 comments
Assignees
Labels

Comments

@abdulwajid725
Copy link

No description provided.

@preco21
Copy link
Owner

preco21 commented Jan 17, 2018

Thank you for reporting this!

Would you mind giving some code example for this issue? So that I can reproduce the issue to see what went wrong.

Also, if available, can I see what images you used for merging?

@sanidhyatandon
Copy link

@preco21 Hi also noted this Issue, if you copy the merged image, with one image small and other large, and then paste it o Microsoft word or Microsoft powerpoint the left out area appears black. I am attaching my code and the images screenshots. I have to correct it in my code so please try to help asap. Thanks.

@sanidhyatandon
Copy link

sanidhyatandon commented Jan 19, 2018

screen shot 2018-01-19 at 1 02 57 pm

screen shot 2017-11-17 at 1 41 43 pm

img-19012018130412
compare_diff

The code is attached above and I am merging the below 3 images

@preco21
Copy link
Owner

preco21 commented Jan 23, 2018

Sorry for the late response and thank you for providing an example.

Not sure if this issue could be on upstream since merge-img rely on it.

@preco21
Copy link
Owner

preco21 commented Jan 23, 2018

@sanidhyatandon Have you tried color option described on the readme?

And make sure your images are all PNG which has alpha channel.

Seems to be these points are unrelated.

@preco21
Copy link
Owner

preco21 commented Jan 23, 2018

I just tried to reproduce this issue with both jpeg and png images in Node v9, it seems to be worked for me:

test

Tested with this code:

import mergeImg from 'merge-img';

(async () => {
  const img = await mergeImg([
    'images/a.png',
    'images/b.jpg',
  ], {offset: 10});

  img.write('test.png');
})();

@abdulwajid725 @sanidhyatandon I'm wonder if you tried to use this module on browser environment or Electron. I haven't considered about that use case.

@preco21 preco21 self-assigned this Jan 23, 2018
@preco21 preco21 added the bug label Jan 23, 2018
@sanidhyatandon
Copy link

@preco21 If for example, image B is smaller than image A, then if I use color option as in readme, then when I copy the merged resultant image and paste it on Microsoft Word or Microsoft Powerpoint, the extra left-out area appears black. I'll show you with an example.
https://lh3.googleusercontent.com/-yxOtjXXjySo/WmgkAt8xAnI/AAAAAAAAARM/lJnGP3Y2coQKcO0-qXK647bzRhKvPjMBgCL0BGAYYCw/h1050/2018-01-23.png

REFER TO THE LINK ABOVE, I have sent the faulty image as on MSWORD

@preco21
Copy link
Owner

preco21 commented Jan 24, 2018

Hmm, very strange to me. Can you file the image here directly instead of MS Word? I'm not sure if this is MS Word specific issue.

And also, again, please let me know what platform (browser, node or Electron) you are currently working on.

@sanidhyatandon
Copy link

@preco21
img-24012018123904

I am using nwj, https://nwjs.io/

@sanidhyatandon
Copy link

@preco I didn't use the color option in the readme for above images, it fills with white.
But if I paste it on MS WORD, it will fill with black. So seems an MS-WORD specific issue for me.

@preco21
Copy link
Owner

preco21 commented Jan 24, 2018

@sanidhyatandon Yep it seems so. I cannot see background color for your given image. The background of the image is fully transparent.

@preco21
Copy link
Owner

preco21 commented Jan 24, 2018

@abdulwajid725 Are you still having issue now?

@preco21 preco21 mentioned this issue Jan 31, 2018
7 tasks
@Allyday
Copy link

Allyday commented Feb 17, 2020

Hi, I'm having a similar issue: I'm also merging images varying in sizes.
However, my output is a JPEG file, not PNG. And so instead of transparent gaps, they're just black. (To replicate the issue, you can change the output path to .jpeg instead of .png).

The color option doesn't work for me as it only takes values of number type, while hex values also include letters (from a to f). I hope you could update it to take values of string type in the future as well :)

I managed to work around this by stretching my own images before merging them, but if this issue could be updated in the coming version it would be great!

Nevertheless, this is a wonderful & very useful package. Thanks a lot for creating it :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants