Comments (5)
Update: Yes, it looks like sRGB issue, either with PIL, with aggdraw, or with the PNG writer in PIL.
I added this piece of code at the end:
from PIL.ImageCms import buildTransform, applyTransform
# SRGB_PROFILE = 'sRGB.icc'
SRGB_PROFILE = '/usr/share/color/icc/sRGB.icc'
LINEARIZED_PROFILE = 'linearized-sRGB.icc'
LINEARIZED_TO_SRGB = buildTransform(LINEARIZED_PROFILE, SRGB_PROFILE, 'RGB', 'RGB')
img = applyTransform(img, LINEARIZED_TO_SRGB)
img.save("dump2.png")
The color profile icc file I got from: python-pillow/Pillow#1604 (comment) based on this post: https://stackoverflow.com/questions/31300865/srgb-aware-image-resize-in-pillow/46613620#46613620
And the result looks much better:
from aggdraw.
Wow, nice examples. Thanks for reporting this.
Could you do a couple things for me?
-
Could you make a simple example script that includes all the data (x/y locations) needs to reproduce an image that shows this problem? That way I can test it locally.
-
Could you try this with installing from the current aggdraw master branch? You should be able to do
pip install git+https://github.com/pytroll/aggdraw.git
. Note that there are other issues we've discovered in the master branch that are being talked about in other issues/PRs so results may not be perfect.
I'm not sure there is much aggdraw, the python package, can do to resolve this unless it is specifically a bug of aggdraw improperly passing things between python and C. Aggdraw depends almost entirely on the antigrain (agg) C library. We keep a copy of it alongside aggdraw in this repository, but it is coming from another group. The reason I asked about you using the master branch is that we are working on switching to agg 2.4 (I think that's the version, can't remember offhand) which had a lot of changes done from the previous versions we used.
If the master branch gives you "better" results then this must be an agg C problem. If not, then it could still be an agg problem or a PIL problem as you've deduced already.
from aggdraw.
A full script to reproduce the issue in the attachment:
from aggdraw.
I'm pretty swamped this month, but might have time to look at this this weekend. @baryluk Did you have time to try the master branch and compare it?
Edit: And of course, thank you for putting together this example code and images.
from aggdraw.
Tested the master branch at commit 6c1cf87 , and confirmed the code is using the locally compiled version.
Same results.
It looks the issue is that the PIL doesn't really understand color spaces, nor the image metadata carry this information. If the PIL supported 16-bit per channel, or multi channel f32 formats, that would be less of an issue.
I did modify aggdraw.cxx
line 407 , in the method draw_adaptor::setantialias
I did this:
void setantialias(bool flag)
{
if (flag) {
// rasterizer.gamma(agg::gamma_power(1.0/2.4));
rasterizer.gamma(&agg::linear_to_sRGB);
} else
rasterizer.gamma(agg::gamma_threshold(0.5));
};
Instead of using rasterizer.gamma(agg::gamma_linear());
, and this works and fixes the issue.
from aggdraw.
Related Issues (20)
- antigrain.com is squatted HOT 6
- multline text not supported HOT 1
- Resolve differences after agg 2.2 and agg 2.4 migration HOT 3
- aggdraw.Draw, aggdraw.Pen, aggdraw.Brush, etc... are not extendable (apparently) HOT 1
- Cannot install on Windows HOT 2
- MNT: Stop using ci-helpers in appveyor.yml HOT 1
- documentation has left the chat. HOT 1
- Latest Documentation? HOT 7
- pip install results in error Windows 10 21H1 HOT 4
- aggdraw does not some to be able to find fonts when installed in a venv HOT 3
- No arc symbols? HOT 1
- is there a way to draw squircle (rectangle with rounded edges) ? HOT 4
- Add support to release linux aarch64 wheels HOT 3
- PyPy3.8 support HOT 6
- Windows binaries are missing for aggdraw 1.3.13 on pypi.org HOT 4
- The value in the coordinates list cannot exceed 32767. HOT 1
- Diferences between pip version and source-compiled version HOT 4
- Misleading information in the document HOT 6
- freetype not linked correctly in latest macOS Python 3.11 wheels (1.3.17 and 1.3.18) HOT 19
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 aggdraw.