3 users online. Create an account or sign in to join them.Users
This is an open discussion with 23 replies, filed under General.
Hello, has anyone had difficulty using JIT with alpha transparent pngs?
Without JIT, the images shows fine.
When using JIT, the transparent background turns black.
The PNGs were exported with Fireworks using 8-bit/256 colors/Adaptive, Alpha Transparency with a white matte.
Can anyone help me? Is there a certain setting in JIT to maintain transparency?
As of version 1.04, JIT supports alpha transparent images. I have already tried it once and it worked. What version are you using?
Version 1.07 (the latest one). Running Symphony 2.06.
Is there an update to this thread?
Symphony 2.1 JIT 1.09 no transparency.
I’m having this exact problem on Symphony 2.1.1 and JIT 1.09
In mode 2 (only!) there’s a black backrground color in semi-transparent images.
I realize this problem has come up a lot of times in various threads. However, I’ve not discovered if it is/can be solved. The most relevant reply to this specific bug seems to be Alistair’s reply here but he does not mention a solution.
Try this; just before this line add the following:
@brendo thanks for the tip.
It does not seem to make a difference (and yes I emptied the manifest/cache :) )
Hmm, if you comment out this line, does that help?
Nope. But I’ve found a way.
Check out this comment and add the following to class.image.php around line 141:
// as per: http://fi.php.net/manual/en/function.imagecreatetruecolor.php#54025
$colourBlack = imagecolorallocatealpha($this->_resource, 0, 0, 0, 127);
This makes the background transparent (yay!) but it also seems to set a ‘matte’ to black which results in a crappy ‘outline’ (booh!).
For my purposes (and I’m guessing for 90% of the cases) it would be better to just have a white background fill. Would it be a simple workaround to change the auto-fill of black to white instead?
Oh, excellent, I’m sure this will help many :)
Well, not really since it’s only acceptable when the image has no need for (semi-transparent) anti-aliased edges.
Checkout my attachment in which it is, IMHO, not acceptable :-(
(The gray background is actually my OSX ‘Preview’ canvas: the image is truly transparent but the edges are ugly)
I’m still searching for a way to have proper anti-aliassed ‘matting’, OR to have a filled white background instead of the black.
I’m afraid someone who actually knows PHP will have to pick it up. My best guess is that there’s some issues with the __fill function in class.imagefilter.php.
I noticed the function uses imagecolorallocate() which does not handle ‘alpha’ values. imagecolorallocatealpha() does.
Another thing I noticed was that $colour in class.imagefilter.php defaults to 000 (black) while $background_fill in filter.crop.php defaults to fff (white).
Workaround: default to white background instead of black:
To have a background fill of white instead of black I do the following:
$whiteBG = imagecolorallocate($tmp, 255, 255, 255);
ImageFill($tmp, 0, 0 , $whiteBG);
This will not take care of transparency but will fill the background with white which I find more appropriate in 90% of the uses. Why the core function self::__fill() does not work, and how to add support for transparency (with imagecolorallocatealpha()?), I dont exactly know. Someone more experienced in PHP would figure this out quickly I guess.
I thought you could pass the preferred background colour in the URL? Maybe that was a customised version I used years ago.
@nickdunn according to the docs that only seems to apply to mode 3 but I believe it should be possible to supply a background-color for mode 2 too. Alistair mentioned this but I have not read about a fix/patch/solution anywhere yet.
It’s probably not too difficult to implement but I do not have the time to look into it at the moment so I went with the quick workaround (a white background fill)
I apologize for the long thread and all but I think I have found a fix (on SO)
Add the following code:
$transparent = imagecolorallocatealpha($tmp, 255, 255, 255, 127);
imagefilledrectangle($tmp, 0, 0, $dstw, $dsth, $transparent);
This fixes things with me locally: it retains the (semi-transparent) background.
Note I am no PHP programmer, here might be dragons!
Another useful webpage I found describes a more thorough approach(?)
PHP Wizards: Please take a look and see if this can be fixed properly.
btw, future readers: this fix applies to /lib/filters/filter.crop.php
edit: just noticed that was already pointed out. well i can at least offer this: the $dst variables have hidden underscores! beware!
okay, so .. is it possible? has JIT been updated? I just pulled from git and it doesn't scale png's :(
Any way to implement this into JIT ?
davidhund's patch works, and it's a simple fix. i'll get a repo going with the change soon, though, for people who don't want to edit the extension.
Create an account or sign in to comment.
Contact the team
Symphony • Open Source XSLT CMS