question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to create a transparent image

See original GitHub issue

Hello,

I’m trying to create a blank transparent Jimp image, but it always has a color value. I tried using the opacity method, but it doesn’t seem to work.

Here is my code:

var mainImage = new Jimp(caseWidth, caseHeight, function (err, image) {
     image.opacity(0, function(err, image) {
          image.write(caseImage);
     });
});

It creates the new image, but it is all black and will not become transparent. I have tried using both the mainImage and reading the caseImage again, but they are both all black.

Is there something I am missing?

Thanks.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:5

github_iconTop GitHub Comments

13reactions
mikechuckcommented, Jul 21, 2017

Turns out you can’t have a transparent jpg… Thanks!

7reactions
netuxcommented, Jul 20, 2017

You can add an optional background color argument to the Jimp constructor:

var mainImage = new Jimp(caseWidth, caseHeight, 0x0, function (err, image) {
    // do stuff with image
});

(0x0 = 0 = rgba(0, 0, 0, 0))

Read more comments on GitHub >

github_iconTop Results From Across the Web

Free Transparent Background Maker | Adobe Express
Create images with transparent backgrounds for free with Adobe Express. Make your image transparent by removing the background in one click to create...
Read more >
Make an Image Background Transparent - Free Online Tool
Automatically remove background of any image and make it transparent. Upload your photo now & see the magic.
Read more >
9 Quick Ways to Make an Image Transparent on Windows and ...
9 Quick Ways to Make an Image Transparent on Windows and Mac · Next, select Open > Browse files to open your image....
Read more >
How to Make a Transparent Background - 5 Ways to Remove ...
Step 1. Open Logo File · Step 2. Add A Transparent Layer · Step 3. Delete the background · Step 4. Save As...
Read more >
How to Make an Image Background Transparent - MakeUseOf
In the Picture Format menu, there is a button called Remove Background. When you click it, the software will identify what it perceives...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found