file_put_contents() is issuing an error when trying to export an image

前端 未结 4 963
攒了一身酷
攒了一身酷 2021-01-19 20:36

I have created an image by copying a number of images into a new one. In the last step of my program, I am trying to export this file into a folder.

The code is as

4条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-01-19 21:08

    With another question, I was able to finally get the code working.

    Solution: The problem was that I was trying to use the file_put_contents to dump a GD handle and, as it turned out, it is not as simple as that. I was directed to the imagepng function which would take the directory as the second argument for exporting the file.

    Program: I made a program to download the strips from the webcomic Fredo and Pidjin so that I can read it later when I don't have access to the internet. The program is given below.

    find('div[class=episode] p img');
    
        $newHeight = 0;
    
        for($iii=0; $iiisrc;
            $img[$iii] = imagecreatefromstring(file_get_contents($storage[$iii]));
    
            $width[$iii] = imagesx($img[$iii]);
            $height[$iii] = imagesy($img[$iii]);
    
            $newHeight += ($height[$iii] + 30);
        }
    
        $newWidth = max($width);
        $cummDestHeight = 0;
    
        $export = imagecreatetruecolor($newWidth, $newHeight);
        imagefill($export, 0,0, 0xFFFFFF);
    
        for($iii=0;$iiifind('span[class=next] a[rel=next]');
        $next = $nextUrl[0]->href;
        $counter++;
    }
    

    ?>

    Note: I have used the Simple HTML DOM Parser to scrape the source and look through the DOM.

    Cheers.

提交回复
热议问题