I have an issue for image rotation. There are two step process 1) Upload 2) Crop. On the 1st Step when I am uploading image I am moving using following script.
<?php
........
$output_dir = "uploads/";
$fileName = time() . rand();
$upload = $output_dir.$fileName;
move_uploaded_file($_FILES["myfile"]["tmp_name"],$upload);
setcookie("upload", $upload, time()+3600);
....
....
?>
Note : Assuming the image uploaded is with .jpg extension.
After above code execution it generates a file like 14278875238271 which contains high resolution image object and 14278875238271.jpg which is low resolution image.
Now once this image is uploaded moving to next step crop page..... This page shows low resolution image 14278875238271.jpg to crop in circle format, now if anyone want to rotate image there is button to rotate left / right and on clicking on that button I am executing the following function code.
function rotateImage($sourceFile,$angle=0){
$imageinfo=getimagesize($sourceFile);
$bgColour = 0xFFFFFF;
/*---For low resolution image ----*/
$original = imagecreatefromjpeg($sourceFile);
$rotated = imagerotate($original, $angle, $bgColour);
$rotated = imagejpeg($rotated,$sourceFile,100);
/*---Rotate Origianl File also----*/
$upload=$_COOKIE['upload'];
$original = imagecreatefromjpeg($upload);
$rotated = imagerotate($original, $angle, $bgColour);
imagejpeg($rotated,$upload."rotate",100);
setcookie("upload", $upload."rotate", time()+3600);
}
Now the main issue is that after execution the rotation code new original rotation file is of double size and it's creating problem in processing next steps.
Can anyone help in this regard ?
I tried to explain as simple as I can but even it's not clear please let me know.
Note : Every time I am using the file stored in $_COOKIE['upload'], which is actual resolution.
Aucun commentaire:
Enregistrer un commentaire