O redimensionamento com GD gera imagens em preto

O que pode fazer com que o php gd produza uma imagem em preto após o redimensionamento? O código a seguir sempre gera uma imagem em preto para cada arquivo jpeg válido.

<?php

$filename = 'test.jpg';
$percent = 0.5;

header('Content-Type: image/jpeg');

list($width, $height) = getimagesize($filename);
$newwidth = $width * $percent;
$newheight = $height * $percent;

$thumb = imagecreatetruecolor($newwidth, $newheight);
$source = imagecreatefromjpeg($filename);

imagecopyresized($thumb, $source, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);

imagejpeg($thumb);
imagedestroy($thumb);
?>

saída degd_info():

  Array
(
    [GD Version] => bundled (2.1.0 compatible)
    [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] => 
    [XBM Support] => 1
    [JIS-mapped Japanese Font Support] => 
)

O código apareceu funcionando em outros ambientes. Provavelmente está relacionado ao SO, pacotes instalados, bibliotecas, etc?

questionAnswers(4)

yourAnswerToTheQuestion