Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Not really a bug: I realized problems with missing anti aliasing effect on some fonts.
After looking at the code I added at line 704 in signwriter.module
the following:
imageantialias($im, true);
it's before
$background = imagecolorallocate($im, $bg[0], $bg[1], $bg[2]);
$foreground = imagecolorallocate($im, $fg[0], $fg[1], $fg[2]);
$shadow_color = imagecolorallocate($im, $shadow_rgb[0], $shadow_rgb[1], $shadow_rgb[2]);
This worked for me.
Maybe it should be added in the next version? Or maybe there's a better way to handle it!?
Comment | File | Size | Author |
---|---|---|---|
#20 | Picture 1.png | 88.9 KB | dcasey |
Comments
Comment #1
szy CreditAttribution: szy commentedIn order to have good looking antialiased heading in 6th Drupal, it's enough to define
your color of the background, even if transparent.
:]
Agileware & Co. - thanks for your work! :]
Szy.
Comment #2
Agileware CreditAttribution: Agileware commentedThanks szy!
@Riggs333 - Can you provide some URL examples where anti-aliases does not work? And details of the signwriter configuration used?
Comment #3
szy CreditAttribution: szy commented@Agileware - have a white (or any other light one) background on your page,
tickle 'transparent' and leave color value for background empty - then you'll get
ugly black dots around the letters.
Szy.
Comment #4
dman CreditAttribution: dman commentedTrue.
The answer is indeed to set a proper background color.
BUT it would be better if PNG transparency was being antialiased correctly through the alpha channel. Even with PNG I was seeing black chunks.
imagesavealpha() may help if imageantialias() doesn't.
Another suggested approach I saw in php.net was to clear the background by filling the image with solid transparent bg color before starting to draw on it.
Comment #5
smithn.nc CreditAttribution: smithn.nc commentedSubscribing. This module seems perfect for a project of mine, but only if the images are PNGs with alpha channel transparency.
Comment #6
jide CreditAttribution: jide commentedI borrowed this little piece of code from textimage and it works for 6.x-1.1.
Add this just before line 927 :
This should also work with 5.x.
Should I open a separate issue for 6.x branch ?
Comment #7
Agileware CreditAttribution: Agileware commentedNo, it's the same issue for both so this one will do for both versions.
Comment #8
Deciphered CreditAttribution: Deciphered commentedHi guys,
If you're stealing code from my dear Textimage (I jest, steal away :)) you should probably take code from the latest versions.
The transparency support has been vastly improved since the code in #6.
Try the following when creating a transparent background:
Cheers,
Deciphered (maintainer of Textimage).
Comment #9
dman CreditAttribution: dman commentedIndeed. an encoded PNG looks like a terrible idea. Yes, just filling in with transparent is what you need!
Comment #10
jide CreditAttribution: jide commentedDeciphered & dman,
I am not even a good thief ;) Code from latest version seems more efficient, I'll give it a try, thanks !
Comment #11
jide CreditAttribution: jide commentedI have tried to use the #8 code snippet from Deciphered, but i have unconsistent results. Preview seems fine but generated images appear with a black background and fuzzy edges. For now i will stick with the transparent pixel trick, but i'll try harder later.
Comment #12
jide CreditAttribution: jide commentedbtw, to work with Signwriter, code snippet should be :
Comment #13
Cool_Goose CreditAttribution: Cool_Goose commentedjide's version works nicely. Thanks a lot ;). That was exactly what I was looking for.
Comment #14
h-man24 CreditAttribution: h-man24 commentedHello,
i'Ve got a question, i tried using the version 5.x-1.5 and 5.x-1.x-dev, but in both i have no anti-aliasing. I tried using the background-transparent-but-color-trick but it won't work.
Can somebody tell me, where the lines
should be placed in 5.x-1.5 to get i working?
Thanks in advanced for your help and thanks for this awesome and useful tool.
regards
Stefan
Comment #15
Agileware CreditAttribution: Agileware commentedComment #16
jide CreditAttribution: jide commentedTo use my little hack on the 6.x-2.0-beta1 version, add the following snippet on line 732 :
Comment #17
donquixote CreditAttribution: donquixote commentedhttp://us.php.net/manual/en/function.imageantialias.php says:
Maybe the same is true for antialiased text.
Last time when I wanted to anti-alias some GD imagery (rounded corners), I simply created the image in a higher res w/o antialiasing, and then scaled it down with a home-made alpha-aware per-pixel sampling.
It is important to do the weights correctly when scaling down.
(I could post some code, but I would have to spice it up a bit with comments - and I'm too lazy for that)
EDIT:
The hack #16 works for me.
Comment #18
Deciphered CreditAttribution: Deciphered commentedI'm not trying to drive traffic to TextImage, if anything I'm still interested in talking about a merge, but I spent a huge amount of time tweaking the anti-aliasing, transparency and rotation functionality and the code I used and provided a snippet at #8 is much more efficient than that of #16. I would urge the developers to look at the TextImage code (http://cvs.drupal.org/viewvc.py/drupal/contributions/modules/textimage/?...) and borrow code where needed.
Cheers,
Deciphered.
Comment #19
donquixote CreditAttribution: donquixote commentedOr alternatively, paint a transparent rectangle (imagefilledrectangle).
Of course, in combination with imagealphablending and imagesavealpha.
Comment #20
dcasey CreditAttribution: dcasey commentedUsing: signwriter 6.x-2.0-beta1
Am I missing something? I can't seem to get the jaggies to go away, even with the above hacks.
$im
to$image->im
) → unsuccessful. Giving up because maybe I misunderstood what this module can do. :(Is anyone able to get this to work with levels of alpha transparency? I'm able to get the jaggies to match the background color, but I am using random images and Flash movies behind the rendered type. I need PNG-24 levels of transparency or have to go back to sIFR.
Comment #21
jide CreditAttribution: jide commentedIf i remember well, you should NOT check the transparency checkbox when using the hack to make it work.
Comment #22
juanqui_cieri CreditAttribution: juanqui_cieri commentedThat's right, after unchecking "transparent" checkbox in Background Section the code provided in #16 works fine.
Comment #23
JonesUI CreditAttribution: JonesUI commentedDeciphered's code snippet from #8 worked for me...
I'm using 6.x-2.x-dev
Added the snippet just after line 747 ( // pre allocate the colors )
Is Agileware still maintaining this code?
Its been quite a while since I've seen any responses from him/her.
Comment #24
JonesUI CreditAttribution: JonesUI commentedFollowup to #23:
Deciphered's snippet (#8) seemed to work only with SW images that had already been cached.
When attempting to create new SW images, it would only generate black rectangles where the text should be.
I switched to using the snippet from #16 with version 6.x-2.0-beta1 and the jagged pixels are gone and transparency is working correctly.
Comment #25
Agileware CreditAttribution: Agileware commentedStill maintaining signwriter but just very busy with paid work at the moment.
If anyone can make patches it speeds up the process a lot and is greatly appreciated.
Also, if anyone wants to help co-maintain this module send me a message via my contact form.
Comment #26
aschiwi CreditAttribution: aschiwi commentedGreat, thanks for the code in #16. In Signwriter 6.x-2.0-beta2, put the code in line 748.