将图像放入PHP中的图像字符串中


put an image into a string of images in PHP

我想在PHP中把一个图像或标签放入一系列图像中,我搜索了很多,但大多数人都使用图像库来完成。但我想在不使用任何库的情况下完成。例如,我有一个名为"$img"的变量,其中保存了所有图像。现在,如果我这样写,它实际上编辑了一个图像,而不是所有的图像。有人能帮我解决这个问题吗,这样我就可以编辑所有的图像了。

   foreach (.....) {
        // image url or image variable
        $img;
        //// image editing
        header("Content-type: image/jpeg");
        $imgPath = $img;
        $image = imagecreatefromjpeg($img);
        $color = imagecolorallocate($image, 255, 255, 255);
        $string = "MTGx";
        $fontSize = 30;
        $x = 15;
        $y = 15;
        imagestring($image, $fontSize, $x, $y, $string, $color);
      // here it actually print a image and stop proceeding any more, why !!
        imagejpeg($image);

我可以告诉您的是,您正在尝试向浏览器输出多个图像。这是不可能的。请求必须返回一个文件(至少在PHP中是这样(。