Hosting Grumpydev Imageflair locally – part 2 – trying to get the text and images to display
Posted by jpluimers on 2017/04/12
Hosting Grumpydev Imageflair locally ended with two issues left: an empty image and my wish to include more complete StackExchange bits like the current StackExchange flair does.
I thought fixing the empty image would take a rainy day. It actually took a few rainy hours.
No text
The culprit is that I didn’t have the Microsoft Core Fonts for the Web installed. Which was no coincidence as the free download of those from Microsoft terminated in 2002. The upside is that because of their licenses, they are available as open source and most linux distributions have a script package that will download these fonts. OpenSuSE has fetchmsttfonts for this.
Alternatively, you can use the web.archive.org to download manually, but that’s a tad tedious. But if you love tedious: Free downloads – TrueType core fonts for the Web.
zypper install fetchmsttfonts
That installs the fonts in:
/usr/share/fonts/truetypeThe drawback of having fetchmsttfonts is that the original Microsoft versions of these fonts are downloaded from corefonts.sourceforge.net each time the fetchmsttfonts package is updated, potentially overwriting newer versions of the fonts in that directory. If you don’t want that, use the trick at (not yet archived at the WayBack machine) font handling – install fetchmsttfonts, copy fonts, rpm -e fethmsttfonts, copy fonts back.
Having the fonts installed, I thought the only thing I needed to fix were the multiple references in config.php from that pointed to Arial.TTF. I took the poor man’s approach and just did this being in the directory of config.php:
cp /usr/share/fonts/truetype/arial.ttf Arial.TTF
Filled Imageflair
That didn’t work either: still no text showed.
So I decided to run imageFlair.php from the command line after setting $imageflair_debug = true; in config.php which then resulted in all sorts of warnings like
PHP Warning: imagettftext(): Could not find/open font
After reading I decided to build a small php-gd.tester.php script containing phpinfo(); and gd_info showing these portions for PHP GD (non-relevant bits stripped):
| Additional .ini files parsed | /etc/php5/conf.d/ctype.ini, /etc/php5/conf.d/dom.ini, /etc/php5/conf.d/gd.ini, /etc/php5/conf.d/iconv.ini, /etc/php5/conf.d/json.ini, /etc/php5/conf.d/mysql.ini, /etc/php5/conf.d/mysqli.ini, /etc/php5/conf.d/pdo.ini, /etc/php5/conf.d/pdo_mysql.ini, /etc/php5/conf.d/pdo_sqlite.ini, /etc/php5/conf.d/sqlite3.ini, /etc/php5/conf.d/tokenizer.ini, /etc/php5/conf.d/xmlreader.ini, /etc/php5/conf.d/xmlwriter.ini |
gd
| GD Support | enabled |
| GD headers Version | 2.1.1 |
| GD library Version | 2.1.1 |
| FreeType Support | enabled |
| FreeType Linkage | with freetype |
| FreeType Version | 2.6.3 |
| GIF Read Support | enabled |
| GIF Create Support | enabled |
| JPEG Support | enabled |
| libJPEG Version | 8 |
| PNG Support | enabled |
| libPNG Version | 1.6.21 |
| WBMP Support | enabled |
| XPM Support | enabled |
| libXpm Version | 30411 |
| XBM Support | enabled |
| WebP Support | enabled |
And the gd_info dump:
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| echo "<h1>gd_info</h1>"; | |
| $gdInfo = gd_info(); | |
| echo "<table>"; | |
| foreach($gdInfo as $key=>$value) { | |
| echo "<tbody>"; | |
| echo "<tr>"; | |
| echo "<td class='e'>" . $key . "</td>"; | |
| echo "<td class='v'>" . $value . "</td>"; | |
| echo "</tbody>"; | |
| } | |
| echo "</table>"; | |
| ?> |
| GD Version | 2.1.1 |
| FreeType Support | 1 |
| FreeType Linkage | with freetype |
| T1Lib Support | |
| GIF Read Support | 1 |
| GIF Create Support | 1 |
| JPEG Support | 1 |
| PNG Support | 1 |
| WBMP Support | 1 |
| XPM Support | 1 |
| XBM Support | 1 |
| WebP Support | 1 |
| JIS-mapped Japanese Font Support |
Too bad though: no information on where it sources the fonts from.
No image
Having no solution for the font rendering yet, I focussed at the lack of profile picture.
In the past, the images were generated with gravatar information in the JSON, but now that is empty. See for instance the output of http://superuser.com/users/flair/1.json versus his image http://superuser.com/users/flair/1.png
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "id": 1, | |
| "gravatarHtml": { | |
| }, | |
| "profileUrl": "http:\/\/superuser.com\/users\/1\/jeff-atwood", | |
| "displayName": "Jeff Atwood", | |
| "reputation": "14,561", | |
| "badgeHtml": "<span title=\"24 gold badges\"><span class=\"badge1\">●<\/span><span class=\"badgecount\">24<\/span><\/span><span title=\"79 silver badges\"><span class=\"badge2\">●<\/span><span class=\"badgecount\">79<\/span><\/span><span title=\"109 bronze badges\"><span class=\"badge3\">●<\/span><span class=\"badgecount\">109<\/span><\/span>" | |
| } |
That reveals quite a change in the JSON that imageFlair expects. Actually there is a lot of HTML in there.
So decided to try http://superuser.com/users/flair/1 in addition to http://superuser.com/users/flair/1.json with this result:
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> | |
| <html xmlns="http://www.w3.org/1999/xhtml"> | |
| <head> | |
| <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> | |
| <style type="text/css"> | |
| .valuable-flair .userInfo .username a, .valuable-flair .mod-flair | |
| { | |
| color: #1086A4; | |
| } | |
| </style> | |
| <link rel="stylesheet" href="//sstatic.net/flair-Default.css" /> | |
| </head> | |
| <body> | |
| <div class="valuable-flair"> | |
| <div class="gravatar"> | |
| <a title="See my profile on Super User" target="_blank" href="http://superuser.com/users/1/jeff-atwood"><div class="gravatar-wrapper-50"><img src="https://www.gravatar.com/avatar/51d623f33f8b83095db84ff35e15dbe8?s=50&d=identicon&r=PG" alt="" width="50" height="50"></div></a> | |
| </div> | |
| <div class="userInfo"> | |
| <span class="username"><img src="http://superuser.com/favicon.ico" width="16" /><a href="http://superuser.com/users/1/jeff-atwood" target="_blank">Jeff Atwood</a><span class="mod-flair" title="moderator">♦</span></span> | |
| <br /> | |
| <span class="reputation-score" title="reputation score">14,561</span> | |
| <br /> | |
| <span title="24 gold badges"><span class="badge1">●</span><span class="badgecount">24</span></span><span title="79 silver badges"><span class="badge2">●</span><span class="badgecount">79</span></span><span title="109 bronze badges"><span class="badge3">●</span><span class="badgecount">109</span></span> | |
| </div> | |
| </div> | |
| </body> | |
| </html> |
Two downsides here:
- This doesn’t work for the combined stackexchange flair: http://stackexchange.com/users/flair/1.png works, but http://stackexchange.com/users/flair/1 gives a 404.
- Rendering HTML servers side to PNG requires a lot of work.
Time for another rainy day (:
–jeroen
The install log (which includes the EULA):
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # zypper install fetchmsttfonts | |
| Loading repository data… | |
| Reading installed packages… | |
| Resolving package dependencies… | |
| The following 2 NEW packages are going to be installed: | |
| cabextract fetchmsttfonts | |
| 2 new packages to install. | |
| Overall download size: 54.8 KiB. Already cached: 0 B. After the operation, additional 89.4 KiB will be used. | |
| Continue? [y/n/? shows all options] (y): y | |
| Retrieving package cabextract-1.6-2.1.x86_64 (1/2), 33.5 KiB ( 64.7 KiB unpacked) | |
| Retrieving: cabextract-1.6-2.1.x86_64.rpm ………………………………………………………………………………………………….[done] | |
| Retrieving package fetchmsttfonts-11.4-21.2.noarch (2/2), 21.3 KiB ( 24.7 KiB unpacked) | |
| Retrieving: fetchmsttfonts-11.4-21.2.noarch.rpm …………………………………………………………………………………………….[done] | |
| Checking for file conflicts: ……………………………………………………………………………………………………………..[done] | |
| (1/2) Installing: cabextract-1.6-2.1.x86_64 ………………………………………………………………………………………………..[done] | |
| (2/2) Installing: fetchmsttfonts-11.4-21.2.noarch …………………………………………………………………………………………..[done] | |
| Running: fetchmsttfonts-11.4-21.2-fetchmsttfonts.sh.txt (fetchmsttfonts, /var/adm/update-scripts) | |
| note: No proxy is used. Please set the environment variable "http_proxy" | |
| note: to your favorite proxy, if you want to use a proxy for the download. | |
| note: | |
| note: bash: export http_proxy="http://proxy.example.com:3128/" | |
| note: tcsh: setenv http_proxy "http://proxy.example.com:3128/" | |
| EULA: | |
| Fetching … done | |
| Trying to find the fastest server: | |
| jaist … 1 sec | |
| heanet … 0 sec | |
| kent … 1 sec | |
| nchc … 2 sec | |
| easynews … too slow (aborted) | |
| waix … 1 sec | |
| internode … 2 sec | |
| internap … too slow (aborted) | |
| The winner is: >> heanet << | |
| andale32.exe (http://heanet.dl.sourceforge.net/project/corefonts/the%20fonts/final/andale32.exe): | |
| Fetching … done | |
| Extracting … done | |
| arial32.exe (http://heanet.dl.sourceforge.net/project/corefonts/the%20fonts/final/arial32.exe): | |
| Fetching … done | |
| Extracting … done | |
| arialb32.exe (http://heanet.dl.sourceforge.net/project/corefonts/the%20fonts/final/arialb32.exe): | |
| Fetching … done | |
| Extracting … done | |
| comic32.exe (http://heanet.dl.sourceforge.net/project/corefonts/the%20fonts/final/comic32.exe): | |
| Fetching … done | |
| Extracting … done | |
| courie32.exe (http://heanet.dl.sourceforge.net/project/corefonts/the%20fonts/final/courie32.exe): | |
| Fetching … done | |
| Extracting … done | |
| georgi32.exe (http://heanet.dl.sourceforge.net/project/corefonts/the%20fonts/final/georgi32.exe): | |
| Fetching … done | |
| Extracting … done | |
| impact32.exe (http://heanet.dl.sourceforge.net/project/corefonts/the%20fonts/final/impact32.exe): | |
| Fetching … done | |
| Extracting … done | |
| times32.exe (http://heanet.dl.sourceforge.net/project/corefonts/the%20fonts/final/times32.exe): | |
| Fetching … done | |
| Extracting … done | |
| trebuc32.exe (http://heanet.dl.sourceforge.net/project/corefonts/the%20fonts/final/trebuc32.exe): | |
| Fetching … done | |
| Extracting … done | |
| verdan32.exe (http://heanet.dl.sourceforge.net/project/corefonts/the%20fonts/final/verdan32.exe): | |
| Fetching … done | |
| Extracting … done | |
| webdin32.exe (http://heanet.dl.sourceforge.net/project/corefonts/the%20fonts/final/webdin32.exe): | |
| Fetching … done | |
| Extracting … done | |
| *** Fonts installed. *** | |
| END-USER LICENSE AGREEMENT FOR | |
| MICROSOFT SOFTWARE | |
| IMPORTANT-READ CAREFULLY: This Microsoft End-User License Agreement ("EULA") is | |
| a legal agreement between you (either an individual or a single entity) and | |
| Microsoft Corporation for the Microsoft software accompanying this EULA, which | |
| includes computer software and may include associated media, printed materials, | |
| and "on-line" or electronic documentation ("SOFTWARE PRODUCT" or "SOFTWARE"). | |
| By exercising your rights to make and use copies of the SOFTWARE PRODUCT, you | |
| agree to be bound by the terms of this EULA. If you do not agree to the terms | |
| of this EULA, you may not use the SOFTWARE PRODUCT. | |
| SOFTWARE PRODUCT LICENSE | |
| The SOFTWARE PRODUCT is protected by copyright laws and international copyright | |
| treaties, as well as other intellectual property laws and treaties. The | |
| SOFTWARE PRODUCT is licensed, not sold. | |
| 1. GRANT OF LICENSE. This EULA grants you the following rights: | |
| * Installation and Use. You may install and use an unlimited number of copies | |
| of the SOFTWARE PRODUCT. | |
| * Reproduction and Distribution. You may reproduce and distribute an | |
| unlimited number of copies of the SOFTWARE PRODUCT; provided that each copy | |
| shall be a true and complete copy, including all copyright and trademark | |
| notices, and shall be accompanied by a copy of this EULA. Copies of the | |
| SOFTWARE PRODUCT may not be distributed for profit either on a standalone | |
| basis or included as part of your own product. | |
| 2. DESCRIPTION OF OTHER RIGHTS AND LIMITATIONS. | |
| * Limitations on Reverse Engineering, Decompilation, and Disassembly. You may | |
| not reverse engineer, decompile, or disassemble the SOFTWARE PRODUCT, | |
| except and only to the extent that such activity is expressly permitted by | |
| applicable law notwithstanding this limitation. | |
| * Restrictions on Alteration. You may not rename, edit or create any | |
| derivative works from the SOFTWARE PRODUCT, other than subsetting when | |
| embedding them in documents. | |
| * Software Transfer. You may permanently transfer all of your rights under | |
| this EULA, provided the recipient agrees to the terms of this EULA. | |
| * Termination. Without prejudice to any other rights, Microsoft may terminate | |
| this EULA if you fail to comply with the terms and conditions of this EULA. | |
| In such event, you must destroy all copies of the SOFTWARE PRODUCT and all | |
| of its component parts. | |
| 3. COPYRIGHT. All title and copyrights in and to the SOFTWARE PRODUCT | |
| (including but not limited to any images, text, and "applets" incorporated into | |
| the SOFTWARE PRODUCT), the accompanying printed materials, and any copies of | |
| the SOFTWARE PRODUCT are owned by Microsoft or its suppliers. The SOFTWARE | |
| PRODUCT is protected by copyright laws and international treaty provisions. | |
| Therefore, you must treat the SOFTWARE PRODUCT like any other copyrighted | |
| material. | |
| 4. U.S. GOVERNMENT RESTRICTED RIGHTS. The SOFTWARE PRODUCT and documentation | |
| are provided with RESTRICTED RIGHTS. Use, duplication, or disclosure by the | |
| Government is subject to restrictions as set forth in subparagraph (c)(1)(ii) | |
| of the Rights in Technical Data and Computer Software clause at DFARS | |
| 252.227-7013 or subparagraphs (c)(1) and (2) of the Commercial Computer | |
| Software – Restricted Rights at 48 CFR 52.227-19, as applicable. Manufacturer | |
| is Microsoft Corporation/One Microsoft Way/Redmond, WA 98052-6399. | |
| LIMITED WARRANTY | |
| NO WARRANTIES. Microsoft expressly disclaims any warranty for the SOFTWARE | |
| PRODUCT. The SOFTWARE PRODUCT and any related documentation is provided "as is" | |
| without warranty of any kind, either express or implied, including, without | |
| limitation, the implied warranties or merchantability, fitness for a particular | |
| purpose, or noninfringement. The entire risk arising out of use or performance | |
| of the SOFTWARE PRODUCT remains with you. | |
| NO LIABILITY FOR CONSEQUENTIAL DAMAGES. In no event shall Microsoft or its | |
| suppliers be liable for any damages whatsoever (including, without limitation, | |
| damages for loss of business profits, business interruption, loss of business | |
| information, or any other pecuniary loss) arising out of the use of or | |
| inability to use this Microsoft product, even if Microsoft has been advised of | |
| the possibility of such damages. Because some states/jurisdictions do not allow | |
| the exclusion or limitation of liability for consequential or incidental | |
| damages, the above limitation may not apply to you. | |
| MISCELLANEOUS | |
| If you acquired this product in the United States, this EULA is governed by the | |
| laws of the State of Washington. | |
| If this product was acquired outside the United States, then local laws may | |
| apply. | |
| Should you have any questions concerning this EULA, or if you desire to contact | |
| Microsoft for any reason, please contact the Microsoft subsidiary serving your | |
| country, or write: Microsoft Sales Information Center/One Microsoft Way/ | |
| Redmond, WA 98052-6399. | |
| Running: fetchmsttfonts-11.4-21.2-fetchmsttfonts.sh.txt (fetchmsttfonts, /var/adm/update-scripts) ……………………………………………….[done] | |
| Update notifications were received from the following packages: | |
| fetchmsttfonts-11.4-21.2.noarch (/var/adm/update-messages/fetchmsttfonts-11.4-21.2-1) | |
| View the notifications now? [y/n] (n): y |
The EULA shown when pressing y at the end of the install:
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (Use the Enter or Space key to scroll the text by lines or pages.) | |
| Message from package fetchmsttfonts: | |
| END-USER LICENSE AGREEMENT FOR | |
| MICROSOFT SOFTWARE | |
| IMPORTANT-READ CAREFULLY: This Microsoft End-User License Agreement ("EULA") is | |
| a legal agreement between you (either an individual or a single entity) and | |
| Microsoft Corporation for the Microsoft software accompanying this EULA, which | |
| includes computer software and may include associated media, printed materials, | |
| and "on-line" or electronic documentation ("SOFTWARE PRODUCT" or "SOFTWARE"). | |
| By exercising your rights to make and use copies of the SOFTWARE PRODUCT, you | |
| agree to be bound by the terms of this EULA. If you do not agree to the terms | |
| of this EULA, you may not use the SOFTWARE PRODUCT. | |
| SOFTWARE PRODUCT LICENSE | |
| The SOFTWARE PRODUCT is protected by copyright laws and international copyright | |
| treaties, as well as other intellectual property laws and treaties. The | |
| SOFTWARE PRODUCT is licensed, not sold. | |
| 1. GRANT OF LICENSE. This EULA grants you the following rights: | |
| * Installation and Use. You may install and use an unlimited number of copies | |
| of the SOFTWARE PRODUCT. | |
| * Reproduction and Distribution. You may reproduce and distribute an | |
| unlimited number of copies of the SOFTWARE PRODUCT; provided that each copy | |
| shall be a true and complete copy, including all copyright and trademark | |
| notices, and shall be accompanied by a copy of this EULA. Copies of the | |
| SOFTWARE PRODUCT may not be distributed for profit either on a standalone | |
| basis or included as part of your own product. | |
| 2. DESCRIPTION OF OTHER RIGHTS AND LIMITATIONS. | |
| * Limitations on Reverse Engineering, Decompilation, and Disassembly. You may | |
| not reverse engineer, decompile, or disassemble the SOFTWARE PRODUCT, | |
| except and only to the extent that such activity is expressly permitted by | |
| applicable law notwithstanding this limitation. | |
| * Restrictions on Alteration. You may not rename, edit or create any | |
| derivative works from the SOFTWARE PRODUCT, other than subsetting when | |
| embedding them in documents. | |
| * Software Transfer. You may permanently transfer all of your rights under | |
| this EULA, provided the recipient agrees to the terms of this EULA. | |
| * Termination. Without prejudice to any other rights, Microsoft may terminate | |
| this EULA if you fail to comply with the terms and conditions of this EULA. | |
| In such event, you must destroy all copies of the SOFTWARE PRODUCT and all | |
| of its component parts. | |
| 3. COPYRIGHT. All title and copyrights in and to the SOFTWARE PRODUCT | |
| (including but not limited to any images, text, and "applets" incorporated into | |
| the SOFTWARE PRODUCT), the accompanying printed materials, and any copies of | |
| the SOFTWARE PRODUCT are owned by Microsoft or its suppliers. The SOFTWARE | |
| PRODUCT is protected by copyright laws and international treaty provisions. | |
| Therefore, you must treat the SOFTWARE PRODUCT like any other copyrighted | |
| material. | |
| 4. U.S. GOVERNMENT RESTRICTED RIGHTS. The SOFTWARE PRODUCT and documentation | |
| are provided with RESTRICTED RIGHTS. Use, duplication, or disclosure by the | |
| Government is subject to restrictions as set forth in subparagraph (c)(1)(ii) | |
| of the Rights in Technical Data and Computer Software clause at DFARS | |
| 252.227-7013 or subparagraphs (c)(1) and (2) of the Commercial Computer | |
| Software – Restricted Rights at 48 CFR 52.227-19, as applicable. Manufacturer | |
| is Microsoft Corporation/One Microsoft Way/Redmond, WA 98052-6399. | |
| LIMITED WARRANTY | |
| NO WARRANTIES. Microsoft expressly disclaims any warranty for the SOFTWARE | |
| PRODUCT. The SOFTWARE PRODUCT and any related documentation is provided "as is" | |
| without warranty of any kind, either express or implied, including, without | |
| limitation, the implied warranties or merchantability, fitness for a particular | |
| purpose, or noninfringement. The entire risk arising out of use or performance | |
| of the SOFTWARE PRODUCT remains with you. | |
| NO LIABILITY FOR CONSEQUENTIAL DAMAGES. In no event shall Microsoft or its | |
| suppliers be liable for any damages whatsoever (including, without limitation, | |
| damages for loss of business profits, business interruption, loss of business | |
| information, or any other pecuniary loss) arising out of the use of or | |
| inability to use this Microsoft product, even if Microsoft has been advised of | |
| the possibility of such damages. Because some states/jurisdictions do not allow | |
| the exclusion or limitation of liability for consequential or incidental | |
| damages, the above limitation may not apply to you. | |
| MISCELLANEOUS | |
| If you acquired this product in the United States, this EULA is governed by the | |
| laws of the State of Washington. | |
| If this product was acquired outside the United States, then local laws may | |
| apply. | |
| Should you have any questions concerning this EULA, or if you desire to contact | |
| Microsoft for any reason, please contact the Microsoft subsidiary serving your | |
| country, or write: Microsoft Sales Information Center/One Microsoft Way/ | |
| Redmond, WA 98052-6399. | |
| —————————————————————————– | |
| (Press 'q' to exit the pager.) |







Leave a comment