Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/263.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/string/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 图像大小调整不起作用(使用base64)_Php_String_Image_Converter - Fatal编程技术网

Php 图像大小调整不起作用(使用base64)

Php 图像大小调整不起作用(使用base64),php,string,image,converter,Php,String,Image,Converter,下面的代码应该以字符串形式输出调整大小的图像。不幸的是,它只输出MQ==那么我的错误在哪里?非常感谢您的帮助:) 压缩级别不能为100。只有从0到9 imagepng($image_p, null, from 0 to 9); Base64编码您可以使用: ob_start(); imagepng($image_p, null, 9); // got in has to be from 0 to 9 $stream = ob_get_clean(); echo base64_encode($s

下面的代码应该以字符串形式输出调整大小的图像。不幸的是,它只输出MQ==那么我的错误在哪里?非常感谢您的帮助:)


压缩级别不能为100。只有从0到9

imagepng($image_p, null, from 0 to 9);
Base64编码您可以使用:

ob_start();
imagepng($image_p, null, 9); // got in has to be from 0 to 9
$stream = ob_get_clean();
echo base64_encode($stream);
我就是这样做的:

      $Temp_Dump = $_FILES["file"]["tmp_name"];
      // Get new sizes
      list($width, $height) = getimagesize($Temp_Dump);
      $newwidth = 90;
      $newheight = 90;

      // Load
      $Temp_thumb = imagecreatetruecolor($newwidth, $newheight);
      //$source = imagecreatefromjpeg($Temp_Dump);

      if($extension == "jpg" OR $extension=='jpeg'){ 
      $source = ImageCreateFromJpeg($Temp_Dump); 
      }elseif ($extension == "gif"){ 
      $source = ImageCreateFromGIF($Temp_Dump); 
      }elseif ($extension == 'png'){
       $source = imageCreateFromPNG($Temp_Dump);
      }

      // Resize
      imagecopyresized($Temp_thumb, $source, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);
echo base64_编码(文件获取内容($newImage));不起作用
      $Temp_Dump = $_FILES["file"]["tmp_name"];
      // Get new sizes
      list($width, $height) = getimagesize($Temp_Dump);
      $newwidth = 90;
      $newheight = 90;

      // Load
      $Temp_thumb = imagecreatetruecolor($newwidth, $newheight);
      //$source = imagecreatefromjpeg($Temp_Dump);

      if($extension == "jpg" OR $extension=='jpeg'){ 
      $source = ImageCreateFromJpeg($Temp_Dump); 
      }elseif ($extension == "gif"){ 
      $source = ImageCreateFromGIF($Temp_Dump); 
      }elseif ($extension == 'png'){
       $source = imageCreateFromPNG($Temp_Dump);
      }

      // Resize
      imagecopyresized($Temp_thumb, $source, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);