mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-30 01:10:58 +01:00
Fix meme generation for palette PNGs
Summary: Fixes T4125. Indexed / palette PNGs may fail to allocate a proper black for drawing an image border. Test Plan: {F83066} Reviewers: btrahan, asukhachev Reviewed By: asukhachev CC: aran Maniphest Tasks: T4125 Differential Revision: https://secure.phabricator.com/D7604
This commit is contained in:
parent
476b27d9c8
commit
c146c942af
1 changed files with 9 additions and 0 deletions
|
@ -294,6 +294,15 @@ final class PhabricatorImageTransformer {
|
||||||
$lower_text,
|
$lower_text,
|
||||||
$mime_type) {
|
$mime_type) {
|
||||||
$img = imagecreatefromstring($data);
|
$img = imagecreatefromstring($data);
|
||||||
|
|
||||||
|
// Some PNGs have color palettes, and allocating the dark border color
|
||||||
|
// fails and gives us whatever's first in the color table. Copy the image
|
||||||
|
// to a fresh truecolor canvas before working with it.
|
||||||
|
|
||||||
|
$truecolor = imagecreatetruecolor(imagesx($img), imagesy($img));
|
||||||
|
imagecopy($truecolor, $img, 0, 0, 0, 0, imagesx($img), imagesy($img));
|
||||||
|
$img = $truecolor;
|
||||||
|
|
||||||
$phabricator_root = dirname(phutil_get_library_root('phabricator'));
|
$phabricator_root = dirname(phutil_get_library_root('phabricator'));
|
||||||
$font_root = $phabricator_root.'/resources/font/';
|
$font_root = $phabricator_root.'/resources/font/';
|
||||||
$font_path = $font_root.'tuffy.ttf';
|
$font_path = $font_root.'tuffy.ttf';
|
||||||
|
|
Loading…
Reference in a new issue