File: C:/xampp/htdocs/FograCT1/RGBcorrect.php
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>RGB refine</title>
</head>
<body class="oneColElsCtr">
<?php
//error_reporting(0);
$R=$_POST['R'];
$G=$_POST['G'];
$B=$_POST['B'];
$check=1;
$dtime=time();
$input2 = "rgb.txt";
//$icclab="upload/".$filename."T.ti1";
$fh2 = fopen($input2, 'w') or die("can't open file");
$viHead2=$R.",".$G.",".$B.",".$_FILES["jpgfile"]["name"];
fwrite($fh2, $viHead2);
fclose($fh2);
/*
if (isset($_POST["submit"])) {
$file = $_FILES['jpgfile'];
// Create a new finfo object
$finfo = new finfo(FILEINFO_MIME_TYPE);
// Check the MIME type of the file
$fileType = $finfo->file($file['tmp_name']);
if ($fileType == 'image/jpeg') {
// Use Imagick to analyze the image
$imagick = new \Imagick();
$imagick->readImage($file['tmp_name']);
// Get the image's color space
$colorSpace = $imagick->getImageColorspace();
// Imagick::COLORSPACE_RGB = 1, Imagick::COLORSPACE_CMYK = 2
if ($colorSpace == Imagick::COLORSPACE_RGB) {
// Move the file to the desired directory
$targetDirectory = "uploads/";
$targetFile = $targetDirectory . basename($file["name"]);
if (move_uploaded_file($file["tmp_name"], $targetFile)) {
echo "The file " . htmlspecialchars(basename($file["name"])) . " has been uploaded.";
} else {
echo "Sorry, there was an error uploading your file.";
}
} else {
echo "Sorry, only RGB JPEG files are allowed. CMYK JPEG files are not permitted.";
}
} else {
echo "Sorry, only JPG/JPEG files are allowed.";
}
}
*/
echo "<br>wait for python<br>";
//$dStr=substr($dtime,7,9)."-";
//echo "filename:".$_FILES["jpgfile"]["name"];
if ($_FILES["jpgfile"]["error"] > 0)
{
echo "Return Code: " . $_FILES["jpgfile"]["error"] . "<br />";
}
else
{
if (file_exists($_FILES["jpgfile"]["name"]))
{
echo $_FILES["jpgfile"]["name"] . " already exists. ". "<br />";
}
else
{
move_uploaded_file($_FILES["jpgfile"]["tmp_name"],
$_FILES["jpgfile"]["name"]);
echo $_FILES["jpgfile"]["name"] ." upload sucess! " . "<br />";
//sleep(5);
sleep(3);
//echo "echo . | convert ". $upcc24." info:".$filename.".txt";
//exec("echo . | icclu -fb -ip -pl -s 255 sRGB.icm <input2.txt> out2.txt");
//$command = escapeshellcmd('C:\\Users\\fred\\AppData\\Local\\Programs\\Python\\Python37-32\\python.exe C:\\xampp\\htdocs\\FograCT1\\CurveFixing.py');
$command = escapeshellcmd('C:\\Python311\\python.exe C:\\xampp\\htdocs\\FograCT1\\CurveFixing.py');
// Execute the command and capture the output
$output = shell_exec($command);
sleep(3);
echo '<a href="fix-'.$_FILES["jpgfile"]["name"].'">download fixed file here!</a>' . "<br />";
}
}
?>
<tr>
<br />
<td align="center"><font size="-2"> © <a href="mailto:[email protected]">Fred Kuo</a>, 2024. All rights reserved.<br><a href="http://www.fredkuo.idv.tw/wordpress/?p=1025">Read more.</a><br>
</td>
</tr>
</body>
</html>