GifFrameExtractor icon indicating copy to clipboard operation
GifFrameExtractor copied to clipboard

Unable to unlink() the source file after extraction

Open SilasOlatayo opened this issue 9 years ago • 0 comments

@Sybio I was unable to delete the source file after extraction. I was getting permission error and that only occur when i use $gifExtract->extract($rawSource);

So i found out it was a permission issue. So i tried

@chmod($rawSource, 465);
@unlink($rawSource);

But what if the code is running on a shared host with chmod restriction. So I look into the GifFrameExtractor.php file and I found out the file wasn't closed after processing.

So I made a slit tweak by adding $this->closeFile(); and it fix the problem.

private function parseFramesInfo($filename)
    {
        $this->openFile($filename);
        $this->parseGifHeader();
        $this->parseGraphicsExtension(0);
        $this->getApplicationData();
        $this->getApplicationData();
        $this->getFrameString(0);
        $this->parseGraphicsExtension(1);
        $this->getCommentData();
        $this->getApplicationData();
        $this->getFrameString(1);
        
        while (!$this->checkByte(0x3b) && !$this->checkEOF()) {
            
            $this->getCommentData(1);
            $this->parseGraphicsExtension(2);
            $this->getFrameString(2);
            $this->getApplicationData();
        }
        $this->closeFile();
    }

SilasOlatayo avatar Aug 23 '15 17:08 SilasOlatayo