mozahidrana / timthumb

Automatically exported from code.google.com/p/timthumb
0 stars 0 forks source link

Add PNG_IS_TRANSPARENT: Removing alpha trasparency for colored canvas #338

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
As i was writing in issue 337, this code remove the alpha transparency from PNG 
files if the PNG_IS_TRANSPARENT is set to false. 
If you have a png file but no transparency at all and you want to resize your 
image and add a custom background color (canvas_color), you can use this code. 
Instead the original code shows up a transparent background color and doesn't 
show the canvas_color passed by url.

Original issue reported on code.google.com by gianluig...@gmail.com on 12 Feb 2012 at 8:58

Attachments:

GoogleCodeExporter commented 9 years ago
I was looking at this and I could not force the transparency on the border to 
be exchanged for the canvas color. I found this to be helpful for forcing this 
behavior on particular calls. 

I ended up supplimenting this solution with some addictional lines: 

~ line 499  // get standard input properties
        $canvas_trans = (bool) $this->param('ct', '1');

and subing a line the line of code:

~ line 569  if(preg_match('/^image\/png$/i', $mimeType) and 
!(PNG_IS_TRANSPARENT)){ 

for
        if(preg_match('/^image\/png$/i', $mimeType) and !(PNG_IS_TRANSPARENT) and ($canvas_trans)){ 

Original comment by sjmolin...@gmail.com on 18 Feb 2012 at 10:33

GoogleCodeExporter commented 9 years ago
A good upgrade. In this way you can change de default setting for png's 
transparency.

Original comment by gianluig...@gmail.com on 19 Feb 2012 at 10:29

GoogleCodeExporter commented 9 years ago
thanks for the suggestions - I will look at adding these to the next commit

Original comment by BinaryMoon on 20 Feb 2012 at 12:45