0

我正在开发一个主要由图像组成的网站(使用 Drupal 和 php)。在网站的主页上,图像都将应用棕褐色过滤器。

我想使用 imagefilter 在加载到主页时生成图像,但是当我在过滤器之后应用/打印图像时,它会打印垃圾字符。我试过添加

header(.........);

到代码,但只是告诉我图像已损坏并且无法正确显示。下面是我的代码:

//This is the path to the image, it's referenced by what I'm given from Drupal. 
//For Drupalites: I'm loading this manually from view_get_view_result
$image = imagecreatefromjpeg($nodes[0]->images['_original']); 
//Grayscale + colorize = Sepia.
imagefilter($image, IMG_FILTER_GRAYSCALE);
imagefilter($image, IMG_FILTER_COLORIZE, 90, 90, 0);
imagejpeg($image); //I don't want to save the image, so I don't pass a file name
imagedestroy($image);

现在,通过大量的工作和烦恼,我可以使用 CSS 让它工作,但这有点像 hack,如果可能的话,我想避免这样做。我还想提一下,这些图像将与其他元素一起显示在页面上。

如何让它正确显示我的图像过滤器?我用谷歌搜索了我能想到的任何东西都无济于事。上面的代码是从一个内联显示图像的站点复制而来的。

4

0 回答 0