2016-11-17 1 views
0

私は、PHPを使用してdataimage URLを使用して画像を作成しました、作成時に画像サイズを設定する方法、私は以下のPHPコードを使用しています。PHPでデータを使用してイメージを作成する際のイメージサイズの設定方法は?

$imageData=$_POST['post_data']; 
    $filteredData=substr($imageData, strpos($imageData, ",")+1); 
    $unencodedData=base64_decode($filteredData); 
    $fp = fopen('img/test/test.png', 'wb'); 
    fwrite($fp, $unencodedData); 

誰もがここで

答えて

0

を助けてください、更新されたコードです。

$imageData=$_POST['post_data']; 
$filteredData=substr($imageData, strpos($imageData, ",")+1); 
$unencodedData=base64_decode($filteredData); 
$src = imagecreatefromstring($unencodedData); 
$width = imagesx($src); 
$height = imagesy($src); 
$new_w = 200; 
$new_h = 300; 
$img = imagecreatetruecolor($new_w,$new_h); 
imagecopyresized($img,$src,0,0,0,0,$new_w,$new_h,$width,$height); 
imagejpeg($im, 'image.jpg'); 
imagedestroy($im);  
関連する問題