FPDF error: Not a JPEG file: http://10.11.201.93:81/webdocc/uploaded/tes3.jpg

前端 未结 3 1163
半阙折子戏
半阙折子戏 2020-12-07 05:05

I am working with fpdf to convert html to pdf . I have the following html in new.html .


\"\"

3条回答
  •  抹茶落季
    2020-12-07 05:32

    Have found that constructing slideshows with Paintbrush on a MacBook Pro for years have sometimes been saving what "file jpeg_filename.jpg" determines is a PNG, as a JPEG, which is not the end of the world as far as the browsers go rendering this. Within FPDF's fpdf.php I fixed my own shortcomings that were resulting in "FPDF Error: Not a JPEG file" via the kludgy "if($a[2]==3) { return $this->_parsepng($file); }" additional codeline below ...

    function _parsejpg($file)
    {
      // Extract info from a JPEG file
      $a = getimagesize($file);
      if(!$a)
        $this->Error('Missing or incorrect image file: '.$file);
      if($a[2]==3) { return $this->_parsepng($file); }
      if($a[2]!=2)
        $this->Error('Not a JPEG file: '.' '.$a[2].' '.$file);
      if(!isset($a['channels']) || $a['channels']==3)
        $colspace = 'DeviceRGB';
      elseif($a['channels']==4)
        $colspace = 'DeviceCMYK';
      else
        $colspace = 'DeviceGray';
      $bpc = isset($a['bits']) ? $a['bits'] : 8;
      $data = file_get_contents($file);
      return array('w'=>$a[0], 'h'=>$a[1], 'cs'=>$colspace, 'bpc'=>$bpc, 'f'=>'DCTDecode', 'data'=>$data);
    }
    

提交回复
热议问题