Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 593816 - dev-python/pillow-3.1.1[truetype] with media-libs/freetype-2.7 fails test TestImageFont.test_multiline_spacing - AssertionError: average pixel value difference 6.1854 > epsilon 0.5000
Summary: dev-python/pillow-3.1.1[truetype] with media-libs/freetype-2.7 fails test Tes...
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal
Assignee: Python Gentoo Team
URL:
Whiteboard:
Keywords:
: 617254 659504 (view as bug list)
Depends on:
Blocks:
 
Reported: 2016-09-14 20:55 UTC by eroen
Modified: 2018-06-29 02:56 UTC (History)
3 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
build.log (build.log,138.79 KB, text/plain)
2016-09-14 20:55 UTC, eroen
Details
Tests/images/multiline_text_spacing.png (multiline_text_spacing.png,2.77 KB, image/png)
2016-09-14 20:59 UTC, eroen
Details
output.png (output.png,3.12 KB, image/png)
2016-09-14 21:05 UTC, eroen
Details

Note You need to log in before you can comment on or make changes to this bug.
Description eroen 2016-09-14 20:55:13 UTC
Created attachment 445732 [details]
build.log

Tests pass with media-libs/freetype-2.6.5. Toggling USE=cleartype_hinting does not change anything (see also bug 593700).


======================================================================
FAIL: TestImageFont.test_multiline_spacing
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/var/tmp/portage/dev-python/pillow-3.1.1/work/Pillow-3.1.1-python2_7/Tests/test_imagefont.py", line 213, in test_multiline_spacing
    self.assert_image_similar(im, target_img, .5)
  File "/var/tmp/portage/dev-python/pillow-3.1.1/work/Pillow-3.1.1-python2_7/Tests/helper.py", line 100, in assert_image_similar
    ave_diff, epsilon))
AssertionError:  average pixel value difference 6.1854 > epsilon 0.5000
-------------------- >> begin captured logging << --------------------
PIL.PngImagePlugin: DEBUG: STREAM IHDR 16 13
PIL.PngImagePlugin: DEBUG: STREAM IDAT 41 2783
--------------------- >> end captured logging << ---------------------

----------------------------------------------------------------------
Ran 555 tests in 8.929s

FAILED (SKIP=88, failures=1)
 * ERROR: dev-python/pillow-3.1.1::gentoo failed (test phase):
 *   Failed to run 'nosetests -vx Tests/test_000_sanity.py Tests/test_binary.py Tests/test_bmp_reference.py Tests/test_box_blur.py Tests/test_cffi.py Tests/test_decompression_bomb.py Tests/test_features.py Tests/test_file_bmp.py Tests/test_file_bufrstub.py Tests/test_file_cur.py Tests/test_file_dcx.py Tests/test_file_eps.py Tests/test_file_fitsstub.py Tests/test_file_fli.py Tests/test_file_fpx.py Tests/test_file_gbr.py Tests/test_file_gif.py Tests/test_file_gimpgradient.py Tests/test_file_gimppalette.py Tests/test_file_gribstub.py Tests/test_file_hdf5stub.py Tests/test_file_icns.py Tests/test_file_ico.py Tests/test_file_im.py Tests/test_file_iptc.py Tests/test_file_jpeg.py Tests/test_file_jpeg2k.py Tests/test_file_libtiff.py Tests/test_file_libtiff_small.py Tests/test_file_mcidas.py Tests/test_file_mic.py Tests/test_file_mpo.py Tests/test_file_msp.py Tests/test_file_palm.py Tests/test_file_pcd.py Tests/test_file_pcx.py Tests/test_file_pdf.py Tests/test_file_png.py Tests/test_file_ppm.py Tests/test_file_psd.py Tests/test_file_sgi.py Tests/test_file_spider.py Tests/test_file_sun.py Tests/test_file_tar.py Tests/test_file_tga.py Tests/test_file_tiff.py Tests/test_file_tiff_metadata.py Tests/test_file_webp.py Tests/test_file_webp_alpha.py Tests/test_file_webp_lossless.py Tests/test_file_webp_metadata.py Tests/test_file_xbm.py Tests/test_file_xpm.py Tests/test_font_bdf.py Tests/test_font_pcf.py Tests/test_format_hsv.py Tests/test_format_lab.py Tests/test_image.py Tests/test_image_array.py Tests/test_image_convert.py Tests/test_image_copy.py Tests/test_image_crop.py Tests/test_image_draft.py Tests/test_image_filter.py Tests/test_image_frombytes.py Tests/test_image_fromqimage.py Tests/test_image_fromqpixmap.py Tests/test_image_getbands.py Tests/test_image_getbbox.py Tests/test_image_getcolors.py Tests/test_image_getdata.py Tests/test_image_getextrema.py Tests/test_image_getim.py Tests/test_image_getpalette.py Tests/test_image_getpixel.py Tests/test_image_getprojection.py Tests/test_image_histogram.py Tests/test_image_load.py Tests/test_image_mode.py Tests/test_image_point.py Tests/test_image_putalpha.py Tests/test_image_putdata.py Tests/test_image_putpalette.py Tests/test_image_putpixel.py Tests/test_image_quantize.py Tests/test_image_resample.py Tests/test_image_resize.py Tests/test_image_rotate.py Tests/test_image_split.py Tests/test_image_thumbnail.py Tests/test_image_tobitmap.py Tests/test_image_tobytes.py Tests/test_image_toqimage.py Tests/test_image_toqpixmap.py Tests/test_image_transform.py Tests/test_image_transpose.py Tests/test_imagechops.py Tests/test_imagecms.py Tests/test_imagecolor.py Tests/test_imagedraw.py Tests/test_imageenhance.py Tests/test_imagefile.py Tests/test_imagefont.py Tests/test_imagefont_bitmap.py Tests/test_imagegrab.py Tests/test_imagemath.py Tests/test_imagemorph.py Tests/test_imageops.py Tests/test_imageops_usm.py Tests/test_imagepalette.py Tests/test_imagepath.py Tests/test_imageqt.py Tests/test_imagesequence.py Tests/test_imageshow.py Tests/test_imagestat.py Tests/test_imagetk.py Tests/test_imagewin.py Tests/test_imagewin_pointers.py Tests/test_lib_image.py Tests/test_lib_pack.py Tests/test_locale.py Tests/test_mode_i16.py Tests/test_numpy.py Tests/test_olefileio.py Tests/test_pickle.py Tests/test_psdraw.py Tests/test_pyroma.py Tests/test_scipy.py Tests/test_shell_injection.py Tests/test_tiff_ifdrational.py Tests/test_util.py'
 * 
 * Call stack:
 *     ebuild.sh, line  133:  Called src_test
 *   environment, line 3730:  Called distutils-r1_src_test
 *   environment, line 1022:  Called _distutils-r1_run_foreach_impl 'python_test'
 *   environment, line  354:  Called python_foreach_impl 'distutils-r1_run_phase' 'python_test'
 *   environment, line 3219:  Called multibuild_foreach_variant '_python_multibuild_wrapper' 'distutils-r1_run_phase' 'python_test'
 *   environment, line 2324:  Called _multibuild_run '_python_multibuild_wrapper' 'distutils-r1_run_phase' 'python_test'
 *   environment, line 2322:  Called _python_multibuild_wrapper 'distutils-r1_run_phase' 'python_test'
 *   environment, line  630:  Called distutils-r1_run_phase 'python_test'
 *   environment, line  954:  Called python_test
 *   environment, line 3609:  Called virtx 'nosetests' '-vx' 'Tests/test_000_sanity.py' 'Tests/test_binary.py' 'Tests/test_bmp_reference.py' 'Tests/test_box_blur.py' 'Tests/test_cffi.py' 'Tests/test_decompression_bomb.py' 'Tests/test_features.py' 'Tests/test_file_bmp.py' 'Tests/test_file_bufrstub.py' 'Tests/test_file_cur.py' 'Tests/test_file_dcx.py' 'Tests/test_file_eps.py' 'Tests/test_file_fitsstub.py' 'Tests/test_file_fli.py' 'Tests/test_file_fpx.py' 'Tests/test_file_gbr.py' 'Tests/test_file_gif.py' 'Tests/test_file_gimpgradient.py' 'Tests/test_file_gimppalette.py' 'Tests/test_file_gribstub.py' 'Tests/test_file_hdf5stub.py' 'Tests/test_file_icns.py' 'Tests/test_file_ico.py' 'Tests/test_file_im.py' 'Tests/test_file_iptc.py' 'Tests/test_file_jpeg.py' 'Tests/test_file_jpeg2k.py' 'Tests/test_file_libtiff.py' 'Tests/test_file_libtiff_small.py' 'Tests/test_file_mcidas.py' 'Tests/test_file_mic.py' 'Tests/test_file_mpo.py' 'Tests/test_file_msp.py' 'Tests/test_file_palm.py' 'Tests/test_file_pcd.py' 'Tests/test_file_pcx.py' 'Tests/test_file_pdf.py' 'Tests/test_file_png.py' 'Tests/test_file_ppm.py' 'Tests/test_file_psd.py' 'Tests/test_file_sgi.py' 'Tests/test_file_spider.py' 'Tests/test_file_sun.py' 'Tests/test_file_tar.py' 'Tests/test_file_tga.py' 'Tests/test_file_tiff.py' 'Tests/test_file_tiff_metadata.py' 'Tests/test_file_webp.py' 'Tests/test_file_webp_alpha.py' 'Tests/test_file_webp_lossless.py' 'Tests/test_file_webp_metadata.py' 'Tests/test_file_xbm.py' 'Tests/test_file_xpm.py' 'Tests/test_font_bdf.py' 'Tests/test_font_pcf.py' 'Tests/test_format_hsv.py' 'Tests/test_format_lab.py' 'Tests/test_image.py' 'Tests/test_image_array.py' 'Tests/test_image_convert.py' 'Tests/test_image_copy.py' 'Tests/test_image_crop.py' 'Tests/test_image_draft.py' 'Tests/test_image_filter.py' 'Tests/test_image_frombytes.py' 'Tests/test_image_fromqimage.py' 'Tests/test_image_fromqpixmap.py' 'Tests/test_image_getbands.py' 'Tests/test_image_getbbox.py' 'Tests/test_image_getcolors.py' 'Tests/test_image_getdata.py' 'Tests/test_image_getextrema.py' 'Tests/test_image_getim.py' 'Tests/test_image_getpalette.py' 'Tests/test_image_getpixel.py' 'Tests/test_image_getprojection.py' 'Tests/test_image_histogram.py' 'Tests/test_image_load.py' 'Tests/test_image_mode.py' 'Tests/test_image_point.py' 'Tests/test_image_putalpha.py' 'Tests/test_image_putdata.py' 'Tests/test_image_putpalette.py' 'Tests/test_image_putpixel.py' 'Tests/test_image_quantize.py' 'Tests/test_image_resample.py' 'Tests/test_image_resize.py' 'Tests/test_image_rotate.py' 'Tests/test_image_split.py' 'Tests/test_image_thumbnail.py' 'Tests/test_image_tobitmap.py' 'Tests/test_image_tobytes.py' 'Tests/test_image_toqimage.py' 'Tests/test_image_toqpixmap.py' 'Tests/test_image_transform.py' 'Tests/test_image_transpose.py' 'Tests/test_imagechops.py' 'Tests/test_imagecms.py' 'Tests/test_imagecolor.py' 'Tests/test_imagedraw.py' 'Tests/test_imageenhance.py' 'Tests/test_imagefile.py' 'Tests/test_imagefont.py' 'Tests/test_imagefont_bitmap.py' 'Tests/test_imagegrab.py' 'Tests/test_imagemath.py' 'Tests/test_imagemorph.py' 'Tests/test_imageops.py' 'Tests/test_imageops_usm.py' 'Tests/test_imagepalette.py' 'Tests/test_imagepath.py' 'Tests/test_imageqt.py' 'Tests/test_imagesequence.py' 'Tests/test_imageshow.py' 'Tests/test_imagestat.py' 'Tests/test_imagetk.py' 'Tests/test_imagewin.py' 'Tests/test_imagewin_pointers.py' 'Tests/test_lib_image.py' 'Tests/test_lib_pack.py' 'Tests/test_locale.py' 'Tests/test_mode_i16.py' 'Tests/test_numpy.py' 'Tests/test_olefileio.py' 'Tests/test_pickle.py' 'Tests/test_psdraw.py' 'Tests/test_pyroma.py' 'Tests/test_scipy.py' 'Tests/test_shell_injection.py' 'Tests/test_tiff_ifdrational.py' 'Tests/test_util.py'
 *   environment, line 4387:  Called die
 * The specific snippet of code:
 *       [[ ${retval} -ne 0 ]] && die "Failed to run '$@'";
Comment 1 eroen 2016-09-14 20:59:32 UTC
Created attachment 445746 [details]
Tests/images/multiline_text_spacing.png

The failing test:

            def test_multiline_spacing(self):
            ttf = ImageFont.truetype(FONT_PATH, FONT_SIZE)

            im = Image.new(mode='RGB', size=(300, 100))
            draw = ImageDraw.Draw(im)
            draw.multiline_text((0, 0), TEST_TEXT, font=ttf, spacing=10)

            target = 'Tests/images/multiline_text_spacing.png'
            target_img = Image.open(target)

            self.assert_image_similar(im, target_img, .5)
Comment 2 eroen 2016-09-14 21:05:05 UTC
Created attachment 445748 [details]
output.png

Output image generated by adding

    im.save('/tmp/output.png')

after the draw.multiline_text() line.

The clever observer will notice the text in this image is rendered with subpixel antialiasing, while the original image's text is not.
Comment 3 eroen 2016-09-14 21:05:52 UTC
localhost ~ # emerge --info '=dev-python/pillow-3.1.1::gentoo'
Portage 2.2.28 (python 3.4.3-final-0, default/linux/amd64/13.0, gcc-4.9.3, glibc-2.22-r4, 4.4.6-gentoo x86_64)
=================================================================
                         System Settings
=================================================================
System uname: Linux-4.4.6-gentoo-x86_64-Intel-R-_Core-TM-_i5-2520M_CPU_@_2.50GHz-with-gentoo-2.2
KiB Mem:     4043380 total,   3585620 free
KiB Swap:          0 total,         0 free
Timestamp of repository gentoo: Wed, 14 Sep 2016 00:45:01 +0000
sh bash 4.3_p42-r1
ld GNU ld (Gentoo 2.25.1 p1.1) 2.25.1
app-shells/bash:          4.3_p42-r1::gentoo
dev-lang/perl:            5.20.2::gentoo
dev-lang/python:          2.7.10-r1::gentoo, 3.4.3-r1::gentoo
dev-util/pkgconfig:       0.28-r2::gentoo
sys-apps/baselayout:      2.2::gentoo
sys-apps/openrc:          0.21.3::gentoo
sys-apps/sandbox:         2.10-r1::gentoo
sys-devel/autoconf:       2.69::gentoo
sys-devel/automake:       1.14.1::gentoo, 1.15::gentoo
sys-devel/binutils:       2.25.1-r1::gentoo
sys-devel/gcc:            4.9.3::gentoo
sys-devel/gcc-config:     1.7.3::gentoo
sys-devel/libtool:        2.4.6::gentoo
sys-devel/make:           4.1-r1::gentoo
sys-kernel/linux-headers: 4.3::gentoo (virtual/os-headers)
sys-libs/glibc:           2.22-r4::gentoo
Repositories:

gentoo
    location: /usr/portage
    sync-type: rsync
    sync-uri: rsync://rsync.gentoo.org/gentoo-portage
    priority: -1000

ACCEPT_KEYWORDS="amd64"
ACCEPT_LICENSE="* -@EULA"
CBUILD="x86_64-pc-linux-gnu"
CFLAGS="-O2 -pipe"
CHOST="x86_64-pc-linux-gnu"
CONFIG_PROTECT="/etc"
CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/env.d /etc/gconf /etc/gentoo-release /etc/sandbox.d /etc/terminfo"
CXXFLAGS="-O2 -pipe"
DISTDIR="/usr/portage/distfiles"
FCFLAGS="-O2 -pipe"
FEATURES="assume-digests binpkg-logs config-protect-if-modified distlocks ebuild-locks fixlafiles merge-sync news parallel-fetch preserve-libs protect-owned sandbox sfperms strict unknown-features-warn unmerge-logs unmerge-orphans userfetch userpriv usersandbox usersync xattr"
FFLAGS="-O2 -pipe"
GENTOO_MIRRORS="http://distfiles.gentoo.org"
LDFLAGS="-Wl,-O1 -Wl,--as-needed"
PKGDIR="/usr/portage/packages"
PORTAGE_CONFIGROOT="/"
PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --omit-dir-times --compress --force --whole-file --delete --stats --human-readable --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages --exclude=/.git"
PORTAGE_TMPDIR="/var/tmp"
USE="acl amd64 berkdb bindist bzip2 cli cracklib crypt cxx dri fortran gdbm iconv ipv6 mmx mmxext modules multilib ncurses nls nptl openmp pam pcre readline seccomp session sse sse2 ssl tcpd unicode xattr zlib" ABI_X86="64" ALSA_CARDS="ali5451 als4000 atiixp atiixp-modem bt87x ca0106 cmipci emu10k1x ens1370 ens1371 es1938 es1968 fm801 hda-intel intel8x0 intel8x0m maestro3 trident usb-audio via82xx via82xx-modem ymfpci" APACHE2_MODULES="authn_core authz_core socache_shmcb unixd actions alias auth_basic authn_alias authn_anon authn_dbm authn_default authn_file authz_dbm authz_default authz_groupfile authz_host authz_owner authz_user autoindex cache cgi cgid dav dav_fs dav_lock deflate dir disk_cache env expires ext_filter file_cache filter headers include info log_config logio mem_cache mime mime_magic negotiation rewrite setenvif speling status unique_id userdir usertrack vhost_alias" CALLIGRA_FEATURES="kexi words flow plan sheets stage tables krita karbon braindump author" CAMERAS="ptp2" COLLECTD_PLUGINS="df interface irq load memory rrdtool swap syslog" CPU_FLAGS_X86="mmx sse sse2" ELIBC="glibc" GPSD_PROTOCOLS="ashtech aivdm earthmate evermore fv18 garmin garmintxt gpsclock itrax mtk3301 nmea ntrip navcom oceanserver oldstyle oncore rtcm104v2 rtcm104v3 sirf superstar2 timing tsip tripmate tnt ublox ubx" INPUT_DEVICES="keyboard mouse evdev" KERNEL="linux" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" LIBREOFFICE_EXTENSIONS="presenter-console presenter-minimizer" OFFICE_IMPLEMENTATION="libreoffice" PHP_TARGETS="php5-6" PYTHON_SINGLE_TARGET="python2_7" PYTHON_TARGETS="python2_7 python3_4" RUBY_TARGETS="ruby20 ruby21" USERLAND="GNU" XTABLES_ADDONS="quota2 psd pknock lscan length2 ipv4options ipset ipp2p iface geoip fuzzy condition tee tarpit sysrq steal rawnat logmark ipmark dhcpmac delude chaos account"
Unset:  CC, CPPFLAGS, CTARGET, CXX, EMERGE_DEFAULT_OPTS, INSTALL_MASK, LANG, LC_ALL, MAKEOPTS, PORTAGE_BUNZIP2_COMMAND, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS, USE_PYTHON

localhost ~ # emerge -pqv '=dev-python/pillow-3.1.1::gentoo'
[ebuild  N    ] dev-python/pillow-3.1.1  USE="jpeg {test} tiff truetype zlib -doc -examples -jpeg2k -lcms -tk -webp" PYTHON_TARGETS="python2_7 python3_4 -pypy (-python3_3) -python3_5" 

 * IMPORTANT: 10 news items need reading for repository 'gentoo'.
 * Use eselect news read to view new items.
Comment 4 Virgil Dupras (RETIRED) gentoo-dev 2018-06-28 01:53:17 UTC
*** Bug 617254 has been marked as a duplicate of this bug. ***
Comment 5 Virgil Dupras (RETIRED) gentoo-dev 2018-06-28 02:05:20 UTC
From what I gather from https://github.com/python-pillow/Pillow/issues/2116 and https://github.com/python-pillow/Pillow/issues/2954, the root of this issue seems to be the flakiness of this particular test: it is very sensible to freetype's exact version.

For example, I can reproduce the test failure with pillow 4.3.0 (+truetype) and freetype 2.9.1, but if I downgrade to freetype 2.8.2, then the test passes.

I'm thinking that this kind of test failure will always come back whenever freetype is updated and that this particular test should be disabled.
Comment 6 Virgil Dupras (RETIRED) gentoo-dev 2018-06-29 00:26:25 UTC
*** Bug 659504 has been marked as a duplicate of this bug. ***
Comment 7 Larry the Git Cow gentoo-dev 2018-06-29 02:22:58 UTC
The bug has been closed via the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=7b67f3093ff12c9d291f0e93daf651824dc0cdde

commit 7b67f3093ff12c9d291f0e93daf651824dc0cdde
Author:     Virgil Dupras <vdupras@gentoo.org>
AuthorDate: 2018-06-29 02:22:39 +0000
Commit:     Virgil Dupras <vdupras@gentoo.org>
CommitDate: 2018-06-29 02:22:39 +0000

    dev-python/pillow: exclude flaky tests
    
    Closes: https://bugs.gentoo.org/593816
    Package-Manager: Portage-2.3.41, Repoman-2.3.9

 dev-python/pillow/pillow-4.3.0-r1.ebuild | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)
Comment 8 Virgil Dupras (RETIRED) gentoo-dev 2018-06-29 02:46:20 UTC
Ooh, I feel stupid. Had I cared to actually read the pull request I linked, I would have seen that upstream's tests already take freetype differences into account into a METRICS constant and that the only problem was that 4.3.0 was missing metrics for freetype 2.9.

Adding metrics for freetype 2.9 make all tests pass on my machine. Fix incoming.
Comment 9 Larry the Git Cow gentoo-dev 2018-06-29 02:56:43 UTC
The bug has been closed via the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=7dd0d64be1679025f5cc9c46da39b5b3ed2f8298

commit 7dd0d64be1679025f5cc9c46da39b5b3ed2f8298
Author:     Virgil Dupras <vdupras@gentoo.org>
AuthorDate: 2018-06-29 02:54:27 +0000
Commit:     Virgil Dupras <vdupras@gentoo.org>
CommitDate: 2018-06-29 02:54:27 +0000

    dev-python/pillow: make all tests pass on 4.3.0
    
    Closes: https://bugs.gentoo.org/593816
    Package-Manager: Portage-2.3.41, Repoman-2.3.9

 .../pillow/files/pillow-4.3.0-freetype2.9-test-metrics.patch | 12 ++++++++++++
 dev-python/pillow/pillow-4.3.0-r1.ebuild                     | 12 +++---------
 2 files changed, 15 insertions(+), 9 deletions(-)