# ImageAntialias

- Thread: https://externals.io/message/18757
- Original archive: https://news-web.php.net/php.internals/18757
- Started by Greg Trounson on 2005-09-10T05:41:02+00:00
- Messages: 3
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #18757 — Greg Trounson — 2005-09-10T05:41:02+00:00

URL: https://externals.io/message/18757#18757

Gidday,

Not sure if this is best suited for the devel list or the user list, but 
here goes.:

Antialiasing is a basic requirement for generating professional-quality 
pictures.  Unfortunately the php-gd function imageantialias needs work. 
  Only a small subset of drawing primitives currently make use of 
antialiasing.

See http://www.php.net/manual/en/function.imageantialias.php

To quote, "This function is currently not documented; only the argument 
list is available."  So there is no documented expected behaviour for 
imageantialias.  The only hint of what it can and can't do is in a 
user-contributed comment on the same page (provided by Yours Truly). 
Yet at least one bug report http://bugs.php.net/bug.php?id=24798 has 
been marked as 'bogus', although it is at worst is a reasonable feature 
request if not a bug.


Actually I propose a new method for antialiasing:

bool imageantialias ( resource im, bool on, int MODE )

where MODE is one of:

AA_TRADITIONAL - Perform antialiasing the same way it's done now - that 
is to use a different antialiasing function for each primitive, most of 
which haven't yet been implemented.

AA_SCALE - Draw the image to an internal buffer at 2x the requested 
size, using regular non-antialiased primitives, and downscale the result 
to the requested size with bilinear filtering.  This produces nice 
antialiased images with very little duplication of code across 
primitives.  Line thickness may need to be doubled to give the right effect.

AA_TEXT - Draw/downsample the image as above, but omit text objects 
until after the image has been downsampled.  This allows for clearer but 
non-antialiased text.


Greg

---

## #18761 — Pierre Joye — 2005-09-10T15:29:37+00:00

URL: https://externals.io/message/18757#18761

Hello,

> Not sure if this is best suited for the devel list or the user list, but
> here goes.:
>
> Antialiasing is a basic requirement for generating professional-quality
> pictures.  Unfortunately the php-gd function imageantialias needs work.
>   Only a small subset of drawing primitives currently make use of
> antialiasing.

Yes, only a small set, the lines, ellipse and circles are coming. They
were ready but not synced with the current GD.

> See http://www.php.net/manual/en/function.imageantialias.php
>
> To quote, "This function is currently not documented; only the argument
> list is available."  So there is no documented expected behaviour for
> imageantialias.  The only hint of what it can and can't do is in a
> user-contributed comment on the same page (provided by Yours Truly).
> Yet at least one bug report http://bugs.php.net/bug.php?id=24798 has
> been marked as 'bogus', although it is at worst is a reasonable feature
> request if not a bug.

Doc can be quicly fixed, "It works only with blending mode, no alpha
channel is used."


> Actually I propose a new method for antialiasing:
>
> bool imageantialias ( resource im, bool on, int MODE )
>
> where MODE is one of:
>
> AA_TRADITIONAL - Perform antialiasing the same way it's done now - that
> is to use a different antialiasing function for each primitive, most of
> which haven't yet been implemented.

It is the only possible way right now. The support for the other
primitives are coming (ellipse, circle soon), the problem is a bit
more complex that you may think. Having the good compromise between
speed and quality is not that easy. Keeping in mind that php is a web
language and not a Adobe Illustrator (c) concurrent, with all the
constraints brought by the web environment (server).

> AA_SCALE - Draw the image to an internal buffer at 2x the requested
> size, using regular non-antialiased primitives, and downscale the result
> to the requested size with bilinear filtering.  This produces nice
> antialiased images with very little duplication of code across
> primitives.  Line thickness may need to be doubled to give the right effect.

This is horribly slow and ugly. I'm strongly opposed to implement such
thing in ext/gd.

> AA_TEXT - Draw/downsample the image as above, but omit text objects
> until after the image has been downsampled.  This allows for clearer but
> non-antialiased text.

I fail to see the usage for that, can you bring some basic examples?
Or are you talking about layers?

Regards,

--Pierre

---

## #18762 — Mike Robinson — 2005-09-10T16:34:32+00:00

URL: https://externals.io/message/18757#18762 · In reply to: #18757

Greg Trounson wrote:
> Actually I propose a new method for antialiasing:
> 
> bool imageantialias ( resource im, bool on, int MODE )
> 
> where MODE is one of:
> 
> AA_TRADITIONAL - Perform antialiasing the same way it's done 
> now - that is to use a different antialiasing function for 
> each primitive, most of which haven't yet been implemented.
> 
> AA_SCALE - Draw the image to an internal buffer at 2x the 
> requested size, using regular non-antialiased primitives, and 
> downscale the result to the requested size with bilinear 
> filtering.  This produces nice antialiased images with very 
> little duplication of code across primitives.  Line thickness 
> may need to be doubled to give the right effect.
> 
> AA_TEXT - Draw/downsample the image as above, but omit text 
> objects until after the image has been downsampled.  This 
> allows for clearer but non-antialiased text.

Ugh. Painful short-term remedies...

I understand the frustration, but given the excellent progress made
lately on GD, both by Boutell-folk and the internal GD maintainer(s),
IMHO I think it'd be better to wait until GD handles anti-aliasing
properly.

Best,

Mike Robinson
