简体   繁体   English

上传的图像没有被裁剪

[英]Uploaded image is not getting cropped

I want to upload an image using Android application, through PHP web services. 我想使用Android应用程序通过PHP Web服务上载图像。 The image is getting uploaded but when I want to crop the uploaded image, its failing. 图片正在上传,但是当我想要裁剪上传的图片时,它失败了。 file_exixts condition returns true. file_exixts条件返回true。 Same thing I have tried in my website and its successfully uploading and cropping image. 我在我的网站中尝试过的同一件事及其成功上传和裁剪的图像。

include_once('../crop1.php'); // for cropping an image
include_once('../config.php'); // for encrypting the name of the image

header('Content-Type: bitmap; charset=utf-8'); 
$filename = $_REQUEST['photo'];
$binary = base64_decode($filename);
$encrypted_name = name_encrypt($filename); // encrypting the name of the image

$final = "../upload/".$encrypted_name."jpg"; // Its attaching the extension to the image.

$file = fopen($final, 'wb'); // commented the original code

fwrite($file, $binary); // storing image to the folder


if (file_exists($final))  //checking if image exists
{
    crop_medium($encrypted_name.'jpg'); // if image exists then crop it by calling this function in the included file crop1.php
    $query = "INSERT INTO `error_log` (`param1`, `param2`, `date_time`) VALUES ('1', 'success_found', '2013-07-08')";
    $result = mysql_query($query);
} 

$return["status"] = "OK";
$return["message"] = "Uploaded successfully";

echo json_encode($return);
?>

in crop1.php I've following code 在crop1.php中,我遵循以下代码

<?php
function crop_medium($image_name)
{   
    include_once("resize-class.php"); // calling the php file to resize an uploaded image from the upload folder
    $resizeObj = new resize("upload/$encrypted_name"); 

    $resizeObj -> resizeImage(167, 121, 'crop'); // resizing and image in the given format

    $crop_image = "$encrypted_name";
    $resizeObj -> saveImage("cropped/$crop_image", 100); // saving resized image in other folder
}
?>

I edited my question. 我编辑了问题。 I was passing full path in the parameter, now I am passing only image name through the parameter. 我在参数中传递完整路径,现在我仅通过参数传递图像名称。 Please help me where I am going wrong. 请帮我哪里错了。 Thanks in advance. 提前致谢。

The patermeter variable your passing to the function 模式变量您传递给函数

<?php
function crop_medium($image_name_with_full_path)
{ 

is not what your using in the function. 不是您在函数中使用的。

$resizeObj = new resize("upload/$encrypted_name"); 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM