Comments (13)
Hi,
Thank you for reporting this issue.
I was able to reproduce the issue you have encountered with Thumbnailator 0.4.2.
The root cause is that the original image is a image which is using an indexed
palette with a specific color used for the transparent pixels. (Similar to how
transparent GIFs work)
There is no workaround for this issue (as fixing this problem will require
additional checks in the code), so there isn't anything that can be done at
this moment.
If it is possible, if you can use a PNG image with an actual alpha
(transparency) channel, then it should be able to keep the transparency
correctly.
Original comment by [email protected]
on 11 Nov 2012 at 11:56
- Changed title: Resizing an index-paletted transparent PNG results in a black background
- Changed state: Accepted
- Added labels: Priority-Low
- Removed labels: Priority-Medium
from thumbnailator.
Thank you for your help.
Sincerely
Original comment by [email protected]
on 13 Nov 2012 at 9:25
from thumbnailator.
I would love to see this resolved since I can't control whether the source
image has an alpha channel or not.
Let me know if there's anything I can do.
Original comment by [email protected]
on 13 Feb 2013 at 10:33
from thumbnailator.
Use the following with your image to replace the Transparent Pixels with White
color. It worked perfectly with me.
if( buffered.getColorModel().getTransparency() != Transparency.OPAQUE) {
int w = buffered.getWidth();
int h = buffered.getHeight();
image2 = new BufferedImage(w,h,BufferedImage.TYPE_INT_RGB);
Graphics2D g = image2.createGraphics();
g.setColor(Color.WHITE);
g.fillRect(0,0,w,h);
g.drawRenderedImage(buffered, null);
g.dispose();
}
Thanks..
Original comment by [email protected]
on 25 Feb 2013 at 9:44
from thumbnailator.
[deleted comment]
from thumbnailator.
This happens also with GIFs.
Original comment by [email protected]
on 3 Mar 2013 at 9:41
from thumbnailator.
I have verified that the background will turn black for both PNG and GIF files
(which have a transparent color set in their indexed pallete) using
Thumbnailator 0.4.3 running Java 7.
I will increase the priority of this issue, as it appears to affect more users
than I had initially expected.
I would like to thank everyone who has taken their time to provide input toward
this issue.
Original comment by [email protected]
on 7 Apr 2013 at 8:15
- Added labels: Priority-Medium
- Removed labels: Priority-Low
from thumbnailator.
Plz let the user choose what color to use as background when pngs with
transparency are converted to jpg
Original comment by [email protected]
on 14 May 2013 at 6:31
from thumbnailator.
I would also like to be able to choose what color is used to replace the
transparency.
Original comment by [email protected]
on 4 Dec 2013 at 9:31
from thumbnailator.
I have exactly the same problem. Do we have any update on this?
Original comment by [email protected]
on 12 Aug 2014 at 11:25
from thumbnailator.
Hi guys,
is there any update on this? I ran into the same problem. Would also like to
have an easy way to configure the resulting background color out of a
transparent image.
Original comment by [email protected]
on 9 Sep 2014 at 5:00
from thumbnailator.
HI
I just ran into this issue and cant seem to find a workaround.
E.g if I have a PNG and do this
File fn = new File("test.png") ;
File f = new File("test-small.png)" ;
int s = 300 ;
Thumbnails.of(fn).size(s, s).toFile(f);
The resultant file has a back background when displayed
Original comment by [email protected]
on 17 Mar 2015 at 11:33
Attachments:
- [blackwire-c310-mono (1).png](https://storage.googleapis.com/google-code-attachments/thumbnailator/issue-41/comment-12/blackwire-c310-mono %281%29.png)
- 3487-300.png
from thumbnailator.
Hello there,
Yes, I can confirm that the newly uploaded image also exhibits the same issue
as the image originally attached to this issue. (The image of the star)
The issue with this new image (headset) is also the same as the original image
(star) in that they are both index-paletted PNGs which specifies a specific
color to be transparent.
Original comment by [email protected]
on 18 Mar 2015 at 5:25
from thumbnailator.
Related Issues (20)
- Watermark position incorrect for images re-oriented using EXIF metadata HOT 3
- Move to GitHub (and transition to a Git repository) HOT 5
- Change build from Ant to Maven HOT 4
- Google Project Hosting will drop support for Downloads HOT 3
- Using JAI library? HOT 1
- Thumbnailing problem for a specific JPEG image HOT 1
- OutOfMemoryError: Java heap space / Builder.asBufferedImage HOT 3
- Exception on opening nested folder HOT 5
- Recursively process images in nested directories
- Low quality when resizing a GIF image HOT 2
- Unexpected behaviour when using toFile without an extension matching output format HOT 1
- Support animated GIFs HOT 2
- Javadoc on Thumbnailator class has unclear remark on OutOfMemoryError HOT 3
- Implement a workaround for common OutOfMemoryError cases HOT 15
- java.lang.OutOfMemoryError: Java heap space after adding thumbnailator-feature-oom-workaround-SNAPSHOT.jar file HOT 6
- Please retain debug information in published JAR HOT 3
- forceSize Not maintaining the Aspect Ratio of thr original image HOT 5
- "Image cannot be null" when using `Thumbnails.of(BufferedImage...)` HOT 2
- Use embedded thumbnail from large JPEG images HOT 1
- SVG not supported
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from thumbnailator.