Unable to create thumb, image is black

前端 未结 4 1596
花落未央
花落未央 2021-01-26 03:27

Am uploading Multiple image from single input and create thumb form all uploaded image on fly But when i run code i get only black image but orginal image is same as upl

4条回答
  •  被撕碎了的回忆
    2021-01-26 04:07

    The following code will solve the problem by mapping to the correct imagecreatefrom* function or throw an exception with the invalid image type.

    switch(strtolower($stype)) {
                case 'gif':
                    $simg = imagecreatefromgif($source);
                    break;
                case 'jpg':
                case 'jpeg':
                    $simg = imagecreatefromjpeg($source);
                    break;
                case 'png':
                    $simg = imagecreatefrompng($source);
                    break;
                default:
                throw new \Exception('invalid image type :'.$stype);
                break;
            }
    

提交回复
热议问题