0

I found a php script that saves pictures. Android application refers to a web script when rendering an image. However, images are stored rotated by 90. Do not you know what to add to php script to turn the image to the right side?

php code

if (!empty($_POST)) {

$accountId = isset($_POST['accountId']) ? $_POST['accountId'] : '';
$accessToken = isset($_POST['accessToken']) ? $_POST['accessToken'] : '';

$auth = new auth($dbo);

if (!$auth->authorize($accountId, $accessToken)) {

    api::printError(ERROR_ACCESS_TOKEN, "Error authorization.");
}

if (isset($_FILES['uploaded_file']['name'])) {

    $currentTime = time();
    $uploaded_file_ext = @pathinfo($_FILES['uploaded_file']['name'], PATHINFO_EXTENSION);

    if (@move_uploaded_file($_FILES['uploaded_file']['tmp_name'], "../../".TEMP_PATH."{$currentTime}.".$uploaded_file_ext)) {

        $response = array();

        $imgLib = new imglib($dbo);
        $response = $imgLib->createMyPhoto("../../".TEMP_PATH."{$currentTime}.".$uploaded_file_ext);

        if ($response['error'] === false) {

            $result = array("error" => false,
                            "originPhotoUrl" => $response['originPhotoUrl'],
                            "normalPhotoUrl" => $response['normalPhotoUrl'],
                            "previewPhotoUrl" => $response['previewPhotoUrl']);
        }

        unset($imgLib);
    }
}

echo json_encode($result);
exit;

}

thanks for help

Okas
  • 2,664
  • 1
  • 19
  • 26
  • Can you link to this `imglib`? Are you married to it? Pretty simple task with PHP (GD or imagick usually) https://stackoverflow.com/questions/11259881/how-to-rotate-image-and-save-the-image FIanlly, don't suppress @ errors for no good reason. Will regret it later on. – ficuscr Mar 21 '18 at 22:30
  • I got the idea to try this out> $response = array(); $imgLib = new imglib($dbo); $degrees = 90; $rotate = imagerotate($imgLib, $degrees, 0) $response = $imgLib->createMyPhoto($rotate,"../../".TEMP_PATH."{$currentTime}.".$uploaded_file_ext); Unfortunately, it does not work. I am amateur in PHP – Ondra Souček Mar 21 '18 at 23:05
  • Never heard of `imglib`. It is some third party library you are talking about. Menas nothing to me or probably anyone else here. Unless you can link to that code we can't help you. You don't need to use that library, there are others, more standard, that should work fine. – ficuscr Mar 21 '18 at 23:20

0 Answers0