2016-06-13 13 views
1

ユーザーがhigh quality imageをアップロードしたソーシャルアンドロイドアプリを開発し、ダウンロードしてアプリフィードのリストビューに表示します。PHPで高解像度ではなく低解像度の画像をダウンロード

アップロード画像./uploads/ directory in my server.に私は、サーバーに画像を保存するためにPHPに以下のコードを使用して保存します。

<?php 

// Path to move uploaded files 
error_reporting(E_ALL^E_DEPRECATED); 
include 'conf.php'; 
$target_path = "uploads/"; 

// array for final json respone 
$response = array(); 

// getting server ip address 
$server_ip = gethostbyname(gethostname()); 

// final file url that is being uploaded 
$file_upload_url = 'http://' . $server_ip . '/' . 'AndroidFileUpload' . '/' . $target_path; 


if (isset($_FILES['image']['name'])) { 
    $target_path = $target_path . basename($_FILES['image']['name']); 





    try { 
     // Throws exception incase file is not being moved 
     if (!move_uploaded_file($_FILES['image']['tmp_name'], $target_path)) { 
      // make error flag true 
      print "error1"; 

     } 


print basename($_FILES['image']['name']); 

    } catch (Exception $e) { 
     // Exception occurred. Make error flag true 
     print "error2"; 
    } 
} else { 
    // File parameter is missing 
    print "error3"; 
} 


?> 

は今、私は別のディレクトリ内のすべてのimagelow resolutionを保存したい(またはリアルタイムで低解像度を得ます)それのurlを取得し、phpをアンドロイドアプリに送って、私のアプリのユーザーは、imageの前にthumbnailまたは画像のresolutionを見ることができます。

どうすればいいですか?

+0

[アップロードされた画像からサムネイルを作成する]の可能複製(http://stackoverflow.com/questions/11376315/creating-a-thumbnail-from-an:あなたはこれを行うには、以下のコードを使用することができますアップロードされた画像) – Manikiran

+0

あなたはtimthumb.phpをダウンロードしてサーバーにアップロードすることができ、timthumb.php?scr = image.jpg&h = height&w = width&zc = cropstyle(1,2,3)https:/ /github.com/GabrielGil/TimThumb/blob/master/timthumb.php –

+0

イメージのリサンプリングを意味しますか? 、これをチェックしてください[http://stackoverflow.com/questions/4754594/how-do-you-resize-a-high-resolution-picture-with-php] – ganero

答えて

0

簡単。

<?php 
$org_info = getimagesize("source image"); 
echo $org_info[3] . '<br><br>'; 
$rsr_org = imagecreatefromjpeg("source image"); 
$rsr_scl = imagescale($rsr_org, new_width, new_height, IMG_BICUBIC_FIXED); 
imagejpeg($rsr_scl, "destination image"); 
imagedestroy($rsr_org); 
imagedestroy($rsr_scl); 
?> 
関連する問題