我开发了一个社交Android应用,用户将high quality image
上传到我的服务器,然后将其下载到应用Feed中的列表视图中显示。
在./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";
}
?>
现在,我想将low resolution
中的每个image
保存在不同的目录中(或实时获得低分辨率)并获取url
并使用php
发送到我的应用中的Android应用和用户可以在下载整个thumbnail
之前看到resolution
或低image
的图片。
我应该怎么做?
答案 0 :(得分: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);
?>