HEX
Server: Apache/2.4.46 (Win64) OpenSSL/1.1.1j PHP/8.4.25
System: Windows NT DESKTOP-4TAV2RJ 10.0 build 19045 (Windows 10) AMD64
User: fred (0)
PHP: 8.4.25
Disabled: NONE
Upload Files
File: C:/xampp/htdocs/G7RGB/tvireport.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>TS 10128 Gray Check</title>
<style type="text/css">
<!--
body {
	font: 100% Verdana, Arial, Helvetica, sans-serif;
	background: #ffffff;
	margin: 0; /* 比較好的做法是將 Body 元素的邊界與欄位間隔調整為零,以處理不同的瀏覽器預設值 */
	padding: 0;
	text-align: center; /* 這樣會讓容器在 IE 5* 瀏覽器內置中對齊。然後,文字會在 #container 選取器中設定為靠左對齊預設值 */
	color: #000000;
}
.oneColElsCtr #container {
	width: 46em;
	background: #FFFFFF;
	margin: 0 auto; /* 自動邊界 (搭配寬度) 會讓頁面置中對齊 */
	border: 0px solid #000000;
	text-align: left; /* 這樣做會覆寫 Body 元素上的 text-align: center。 */
}
.oneColElsCtr #mainContent {
	padding: 0 20px; /* 請記住,欄位間隔就是 Div 方塊內部的空間,而邊界就是 Div 方塊外部的空間 */
}
-->
</style></head>

<body class="oneColElsCtr">
<?php
error_reporting(0);
$tvifile= $_GET['tvifile'];
$level= $_GET['level'];
$contact= $_GET['contact'];
$device= $_GET['device'];
$printer= $_GET['printer'];
$date= $_GET['date'];

$sum=260;
$check=1;


	echo "TS 10128 Gray Checking form (RGB)!".$tvifile." " .  "<br />";

	   echo "Report start: " .  "<br />";
     // echo "Stored in: " . "upload/" . $_FILES["file"]["name"]. "<br />";
	  
	  ///parsing start
	  
	  $contents = file("upload/".$tvifile);
		$string = implode($contents);
		//echo $contents[20]; 
		//echo $string; 
$p = ereg_replace("\r\n?", "\n", $string);
$p = str_replace("\n", '', $p);
//echo $p;
function get_between ($text, $s1, $s2) {
$mid_url = "";
$pos_s = strrpos($text,$s1);
$pos_e = strrpos($text,$s2);
for ( $i=$pos_s+strlen($s1) ; (( $i<($pos_e)) && $i < strlen($text)) ; $i++ ) {
$mid_url .= $text[$i];
}
return $mid_url;
}

$datastring=get_between($p,"BEGIN_DATA","END_DATA");

$dot = explode("\t", $datastring);



 $PL=$dot[6];
$Pa=$dot[7];
$Pb=$dot[8];

function getX($L,$a,$b){
$TT=(($a/500)+(($L+16)/116));
if($TT>0.206893) {
$X=96.422*$TT*$TT*$TT;}
else {
$X=96.422*((($a/500)+(($L+16)/116)-(16/116))/7.787);}
return round($X,2);
}
function getY($L,$a,$b){
$TL=($L+16)/116;
IF ($TL>0.206893) {
$Y=100*$TL*$TL*$TL;}
else {
$Y=100*(($L/116)/7.7873);}
return round($Y,2);
}
  
function getZ($L,$a,$b){
$Tb=(($L+16)/116)-($b/200);
IF($Tb>0.206893){
$Z=82.521*$Tb*$Tb*$Tb;}
else {
$Z=82.521*( (($L+16)/116)-($b/200)-(16/116))/7.787;}
return round($Z,2);
}  


$PX=getX($PL,$Pa,$Pb);
$PY=getY($PL,$Pa,$Pb);
$PZ=getZ($PL,$Pa,$Pb);


echo "  <br> 紙張 Lab:".$PL.",".$Pa.",".$Pb;
echo "  <br> L level: ".$level;
echo "  <br> RGB 50% 參考點: 146,146,146 (No.86)";
echo "  <br> RGB 75% 參考點: 92,92,92 (No.163)";
////////////////gray target//////////////////////////////////////////////////////////
//for ( $i = 1; $i <= 22; $i += 1) {  // ${'cde'.$id}=$de;
for ($t=5; $t<=95; $t +=5){
${'tg'.$t.'a'}=$Pa*(1-($t/100));
${'tg'.$t.'b'}=$Pb*(1-($t/100));
}

echo "<br>  50% 灰色目標值 a*, b*:=".$tg50a.", ",$tg50b;
echo "<br>  75% 灰色目標值 a*, b*:=".$tg75a.", ",$tg75b;

$minL50=100;//CMY 30-60
for ($i=6; $i<=18; $i +=1){
$L50=$dot[6+40*$i-$i];

$dLmin=$minL50;
$dL50=abs($L50-$level);///50%目標亮度 target to L=60
$minL50=min($dL50,$dLmin);
if ($minL50==$dL50) {
$Li=$i;
}
}
echo "</br>50%目標亮度差=".round($minL50,2).",   編號=".$Li;

$minG50=100;
for ($i=25; $i<=145; $i +=1){
$g50a=$dot[6+40*$i-$i+1];
$g50b=$dot[6+40*$i-$i+2];
$dchmin=$minG50;
$dch50=pow(pow(($tg50a-$g50a),2)+pow(($tg50b-$g50b),2),0.5);
$minG50=min($dchmin,$dch50);
if ($minG50==$dch50) {
$mi=$i;
}
}

echo "</br>50%最小灰度差=".round($minG50,2).",   編號=".$mi;





$minG75=100;
for ($i=150; $i<=174; $i +=1){
$g75a=$dot[6+40*$i-$i+1];
$g75b=$dot[6+40*$i-$i+2];
$dchmin=$minG75;
$dch75=pow(pow(($tg75a-$g75a),2)+pow(($tg75b-$g75b),2),0.5);
$minG75=min($dchmin,$dch75);
if ($minG75==$dch75) {
$mi75=$i;
}
}

echo "</br>75%最小灰度差".round($minG75,2).",   編號=".$mi75;


for ($j=25; $j<=145; $j +=1) {   ///Gray finder 50%   125+1   50%Gray starting point
	if ($mi==$j) {
$secY=126+floor(($mi-25)/11)*4;///Round fractions down;  11::cycle;  126::starting point;; 125:: starting ID
$secM=126+(($mi-25)%11)*4;/// % Remainder of $x divided by $y
		echo "</br>M50%修正(from 146)=".($secM-146).",  Y50%修正(from 146)=".($secY-146);
		$mm50=$secM-146;$ym50=$secY-146;}

}

for ($j=150; $j<=174; $j +=1) {   ///Gray finder 75%
	if ($mi75==$j) {
$secY75=84+floor(($mi75-150)/5)*4;
$secM75=84+(($mi75-150)%5)*4;
		echo "</br>M75%修正(from 92)=".($secM75-92).",  Y75%修正(from 92)=".($secY75-92);
		$mm75x=$secM75-92;$ym75x=$secY75-92;}

}











 
 ?>  
 
 <table width="200" border="1" align="center">
 <tr>
  <td bgcolor='#aaaaaa'><div align="center">50%最小亮度差</div></td>
  <td><font color="#aaaaaa"><?php echo round($minL50,2);?></font></td>
   <td><div align="center">編號</div></td>
   <td><font color="#aaaaaa"><?php echo round($Li+1,2);?></font></td>
    <td><div align="center">亮度修正</div></td>
   <td><font color="#aaaaaa"><?php $fixL=(13-$Li)*10;echo (13-$Li)*10; //每格為10個數位差//?></font></td>
<td><div align="center">RGB 參考點 </div></td>
   <td><font color="#aaaaaa">146,146,146</font></td>
 </tr>
 

 
<tr>
  <td bgcolor='#999999'><div align="center">50%最小灰度差</div></td>
  <td><font color="#777777"><?php echo round($minG50,2);?></font></td>
   <td><div align="center">編號</div></td>
   <td><font color="#777777"><?php echo round($mi+1,2);?></font></td>
      <td bgcolor='#ff7575'><div align="center">R50%修正</div></td>
   <td><font color="#777777"><?php echo round($mm50,2);?></font></td>
      <td bgcolor='#7466ff'><div align="center">B50%修正</div></td>
   <td><font color="#777777"><?php echo round($ym50,2);?></font></td>
 </tr> 
 
 <tr>
  <td bgcolor='#666666'><div align="center">75%最小灰度差</div></td>
  <td><font color="#444444"><?php echo round($minG75,2);?></font></td>
   <td><div align="center">編號</div></td>
   <td><font color="#444444"><?php echo round($mi75+1,2);?></font></td>
      <td bgcolor='#ff7575'><div align="center">R75%修正</div></td>
   <td><font color="#444444"><?php echo round($mm75x,2);?></font></td>
      <td bgcolor='#7466ff'><div align="center">B75%修正</div></td>
   <td><font color="#444444"><?php echo round($ym75x,2);?></font></td>
 </tr>
 <?php
 $FR=146+($fixL+$mm50);
 $FG= 146+$fixL;
 $FB=146+($fixL+$ym50);
 
$c22=dechex($FR);
$c36=dechex($FG);
$c50=dechex($FB);
$hex="00, 04,00, 05, 00, 02, 00, 00, 00, 00, '0A', '9A', 00, 'FF', 00, 03";
$bindata = pack('hhhhhhhhhhhH*hH*hhhhhhhH*hH*hH*hH*hhhhhhhH*hH*hH*hH*hhhhhhhH*hH*hH*hH*hhhhhhhH*hH*', 00, 04,00,05,00,02,00,00,00,00,00,FF,00,FF,00,03,00,00,00,00,00,$c22,00,'92',00,FF,00,FF,00,03,00,00,00,00,00,$c36,00,'92',00,FF,00,FF,00,03,00,00,00,00,00,$c50,00,'92',00,FF,00,FF,00,02,00,00,00,00,00,FF,00,FF);
$binarydata = pack("vnc*", 0x1234, 0x5678, 65, 66);
file_put_contents('fix.acv', $bindata);
 
 ?>
 
  <tr>
  <td bgcolor='#ff7575'><div align="center">R50%目標</div></td>
  <td><font color="#444444"><?php echo 146+($fixL+$mm50);?></font></td>
   <td bgcolor='#a7ff66'><div align="center">G50%目標</div></td>
   <td><font color="#444444"><?php echo 146+$fixL;?></font></td>
      <td bgcolor='#7466ff'><div align="center">B50%目標</div></td>
   <td><font color="#444444"><?php echo 146+($fixL+$ym50);?></font></td>
   <td><font color="#444444">取得PhotoShop 曲線檔(.acv)</font></td>
   <td><font color="#444444"><a href="fix.acv">here</a></font></td>
      
 </tr>
  </table>
</body>

</html>