如何在不使用 imagepng() 函数的情况下保存图像?

How to save an image without using the imagepng() function?

所以我一直在使用 GD 库处理图像,想先保存这些图像,然后将用户重定向到另一个页面。然而,用 imagepng() 函数似乎是不可能的。

见下文:

/// image manipulations beforehand
imagepng($image, $savepath);
echo '<meta http-equiv="refresh" content="0;URL=different_page.php"/> ';

虽然它确实保存了相关图像,但之后不允许进行任何重定向。因此我的问题是:还有什么其他方法可以在不使用 imagepng 的情况下保存这些图像?

不要使用带 php 的元元素进行重定向,使用 php 位置 header。

imagepng($image, $savepath);
header('Location: different_page.php');