Image rotate save but need to remove old

images php coding issues or problems here.

Moderators: egami, macek, gesf

Post Reply
techker
New php-forum User
New php-forum User
Posts: 14
Joined: Sun Nov 04, 2007 8:05 pm

Mon May 07, 2018 3:06 am

Hey guy's i have this script that works great but only thing is it does not remove the old file?

i think the quality is compromised?could it be?

Code: Select all

session_start();
include_once 'dbconnect.php';


if (!isset($_SESSION['userSession'])) {
	header("Location: index.php");
}

$degrees = -270;
$path = $_GET['Folder'];
$file =$_GET['Pic'];
$fileid =$_GET['id'];

$image = $path.'/'.$file;
$imageN = $path.'/New_'.$file;

$source = imagecreatefromjpeg($image);

$rotate = imagerotate($source, $degrees, 0);

$NewImg='New_'.$file ;

imagejpeg($rotate,$imageN);

imagedestroy($source);
imagedestroy($rotate);
$sql = "UPDATE Coupon_list SET product_image_thumb = '$NewImg' WHERE id = '$fileid'";


if (mysqli_query($DBcon, $sql)) {
   echo "Rotation ok";

echo('<script language="Javascript">opener.window.location.reload(false); window.close();</script>');

} else {
   echo "Error Rotating: " . mysqli_error($DBcon);
  echo "<meta http-equiv=Refresh content=2;url=Coupons.php?>";
}
mysqli_close($DBcon);
?>
<img src='<?php echo $image;?>' ></br>
<img src='<?php echo $imageN;?>'>

User avatar
hyper
php-forum Fan User
php-forum Fan User
Posts: 740
Joined: Mon Feb 22, 2016 5:52 pm

Mon May 07, 2018 7:19 am

To delete a file use unlink / delete.
i think the quality is compromised?could it be?
Could have been, have you looked at the compression setting?

techker
New php-forum User
New php-forum User
Posts: 14
Joined: Sun Nov 04, 2007 8:05 pm

Mon May 07, 2018 7:25 am

i will look at the unlink did not think of that...

as for the compressing were do i see that?

User avatar
hyper
php-forum Fan User
php-forum Fan User
Posts: 740
Joined: Mon Feb 22, 2016 5:52 pm

Mon May 07, 2018 10:12 am

as for the compressing were do i see that?
http://php.net/manual/en/imagick.getcom ... uality.php

Post Reply