phpcheck.jspitgdimage.php Total: 38 Tests, 0 Errors, ↻all
PHPCheck V1.66, OS: Linux, Machine: el8_10.x86_64, PHP-Version: 8.2.28 (64 Bit), Time: 163.744 ms (AVG: 4.309 ms), Memory: 16.0M (512M)
CommentLineCodeResultTest
versions info 29 $info $t->getClassVersion("Jspitgdimage");
$t->check($info, !empty($info) AND $info >= '1.7'); 
[0.064 ms]
'1.7'
Ok
create Basic Image 33 $img imagecreate(150 100);
ImageColorAllocate($img02550);  //green
$colorBlack ImageColorAllocate($img000);
for(
$x=25;$x<150;$x += 25){
  
imageline($img,$x,0,$x,100,$colorBlack);
}
for(
$y=25;$y<100;$y += 25){
  
imageline($img,0,$y,150,$y,$colorBlack);
}  
$Jspitgdimage Jspitgdimage::create($img);
$t->echoImg($Jspitgdimage->img);
$t->checkOutput('img','html'); 
[0.233 ms]
Ok
create jpg File 47 $tmpfname tempnam(sys_get_temp_dir(),'img').'.jpg';
$ok $Jspitgdimage->saveAsFile($tmpfname);
$t->checkEqual($oktrue); 
[0.557 ms]
true
Ok
create class from jpg File 52 $Jspitgdimage Jspitgdimage::create($tmpfname);
$t->check($Jspitgdimage$Jspitgdimage instanceOf Jspitgdimage); 
[0.334 ms]
\JspitGdimage::__set_state(array( 'img' => \GdImage::__set_state(array( )), 'siz ..
Ok
getResolution() 56 $result $Jspitgdimage->getResolution();
$t->checkEqual($result'150 x 100'); 
[0.003 ms]
'150 x 100'
Ok
isTrueColor() 60 $result $Jspitgdimage->isTrueColor();
$t->checkEqual($resulttrue); 
[0.001 ms]
true
Ok
prepare for get mixed color 64 $img2 imagecreatetruecolor(20 20);
$green ImageColorAllocate($img20255,0);  //green
imagefilledrectangle ($img2 0,20$green);
$red ImageColorAllocate($img22550,0);  
imagefilledrectangle ($img2 010 ,2020 $red );
$Jspitgdimage2 Jspitgdimage::create($img2);
$t->echoImg($Jspitgdimage2->img);
$t->checkOutput('img','html'); 
[0.081 ms]
Ok
get mix color $Jspitgdimage2 with red and green 74 $mixColor $Jspitgdimage2->getMixColor();  //size=1
$expected = ['0.0' => 0x0808000];
$t->checkEqual($mixColor$expected); 
[0.016 ms]
array ( '0.0' => 8421376, )
Ok
get mix color $Jspitgdimage2 size=2 79 $mixColor $Jspitgdimage2->getMixColor(2);  
$expected = [ //'y.x' => value
  
'0.0' => 0x000FF00,
  
'0.1' => 0x000FF00,
  
'1.0' => 0x0FF0000,
  
'1.1' => 0x0FF0000,
];
$t->checkEqual($mixColor$expected); 
[0.008 ms]
array ( '0.0' => 65280, '0.1' => 65280, '1.0' => 16711680, '1.1' => 16711680, )
Ok
Convert color to array 89 $colorArray Jspitgdimage::colorToArray(0x07F7F00);
$expected = [
  
'red'=> 0x7F,
  
'green' => 0x7F,
  
'blue' => 0,
  
'alpha' => 0
];
$t->checkEqual($colorArray$expected); 
[0.002 ms]
array ( 'red' => 127, 'green' => 127, 'blue' => 0, 'alpha' => 0, )
Ok
Convert rgb colorarray to hsv color space 99 //yellow
$colors = ['red' => 255'green' => 255'blue' => 0'alpha' => 0];
$hsv Jspitgdimage::rgb2hsv($colors);
$expected = [60.0,100.0,100.0];
$t->checkEqual($hsv$expected); 
[0.006 ms]
array ( 0 => 60.0, 1 => 100.0, 2 => 100.0, )
Ok
Convert rgb colorarray to hsv color space 106 //cyan
$hsv Jspitgdimage::rgb2hsv(0,255,255);
$expected = [180.0,100.0,100.0];
$t->checkEqual($hsv$expected); 
[0.001 ms]
array ( 0 => 180.0, 1 => 100.0, 2 => 100.0, )
Ok
getResolution() 112 $result $Jspitgdimage->getResolution();
$t->checkEqual($result'150 x 100'); 
[0.001 ms]
'150 x 100'
Ok
adjust to 16:9 no scale 116 //adjust tests
$Jspitgdimage->adjust(16,9);
$t->echoImg($Jspitgdimage->img);
$t->checkOutput('img','html'); 
[4.136 ms]
Ok
getResolution() 122 $result $Jspitgdimage->getResolution();
$t->checkEqual($result'150 x 84'); 
[0.002 ms]
'150 x 84'
Ok
adjust to 1:1 no scale 126 $Jspitgdimage->adjust(1,1);
$t->echoImg($Jspitgdimage->img);
$t->checkOutput('img','html'); 
[2.390 ms]
Ok
getResolution() 131 $result $Jspitgdimage->getResolution();
$t->checkEqual($result'84 x 84'); 
[0.001 ms]
'84 x 84'
Ok
adjust to 50 x 50 with scale 135 $Jspitgdimage->adjust(50,50,true);
$t->echoImg($Jspitgdimage->img);
$t->checkOutput('img','html'); 
[1.114 ms]
Ok
getResolution() 140 $result $Jspitgdimage->getResolution();
$t->checkEqual($result'50 x 50'); 
[0.001 ms]
'50 x 50'
Ok
adjust to 2:1 with factor 2 144 $Jspitgdimage->adjust(2,12.0);
$t->echoImg($Jspitgdimage->img);
$t->checkOutput('img','html'); 
[1.192 ms]
Ok
getResolution() 149 $result $Jspitgdimage->getResolution();
$t->check($result'100 x 50'); 
[0.002 ms]
'100 x 50'
Ok
adjust only with factor 1.2 153 $Jspitgdimage->adjust(0,0,1.2);
$t->echoImg($Jspitgdimage->img);
$t->checkOutput('img','html'); 
[2.663 ms]
Ok
getResolution() 158 $result $Jspitgdimage->getResolution();
$t->check($result'120 x 60'); 
[0.001 ms]
'120 x 60'
Ok
reduce width 162 $Jspitgdimage->adjust(100,0,true);
$t->echoImg($Jspitgdimage->img);
$t->checkOutput('img','html'); 
[2.488 ms]
Ok
getResolution() 167 $result $Jspitgdimage->getResolution();
$t->check($result'100 x 60'); 
[0.001 ms]
'100 x 60'
Ok
reduce height 171 $Jspitgdimage->adjust(0,50,true);
$t->echoImg($Jspitgdimage->img);
$t->checkOutput('img','html'); 
[2.516 ms]
Ok
getResolution() 176 $result $Jspitgdimage->getResolution();
$t->check($result'100 x 50'); 
[0.001 ms]
'100 x 50'
Ok
prepare adjust exif orientation 180 //$imgPath = 'https://raw.githubusercontent.com/recurser/exif-orientation-examples/master/Landscape_7x.jpg';
$imgPath 'Landscape_7.jpg';
$gdImageLandcape Jspitgdimage::create($imgPath);
if(
$gdImageLandcape){
  
$gdImageLandcape->adjust(200,150,true);
  
$t->echoImg($gdImageLandcape->img);
}
else {
  echo 
"Error";
}
$t->checkOutput('img','html'); 
[110.9 ms]
Ok
adjust exif orientation 195 $gdImageLandcape->adjustOrientation();
$t->echoImg($gdImageLandcape->img);
$t->checkOutput('img','html'); 
[32.2 ms]
Ok
compare resourcen 201 $img $img2 $Jspitgdimage->getResource();
$t->check('img === img2'$img === $img2); 
[0.005 ms]
'img === img2'
Ok
getResourceCopy 205 $img $Jspitgdimage->getResource();
$imgCopy $Jspitgdimage->getResourceCopy();
$t->check('img !== $imgCopy '$img !== $imgCopy ); 
[0.061 ms]
'img !== $imgCopy '
Ok
compare image content 210 $result $Jspitgdimage->isEqual($imgCopy);
$t->checkEqual($resulttrue); 
[0.168 ms]
true
Ok
get distance to $imgCopy with size 10 214 $dist $Jspitgdimage->distance($imgCopy10);
$t->checkEqual($dist0.0); 
[0.226 ms]
0.0
Ok
modify copy and compare 218 //change 1 pixel
imagesetpixel ($imgCopy 98 48 $colorBlack );
$result $Jspitgdimage->isEqual($imgCopy);
$t->checkEqual($resultfalse); 
[0.148 ms]
false
Ok
get distance to $imgCopy with size 10 224 $dist $Jspitgdimage->distance($imgCopy10);
$t->check($dist$dist 0); 
[0.217 ms]
0.25
Ok
get Position first Pixel Diff 228 $result $Jspitgdimage->firstDiffPos($imgCopy);
$expected = array("x" => 98"y" => 48);
$t->checkEqual($result$expected); 
[0.246 ms]
array ( 'x' => 98, 'y' => 48, )
Ok
saveAsString 233 $Jspitgdimage2 Jspitgdimage::create($tmpfname);
imagepng($Jspitgdimage2->img,$tmpfname,0);
$binStr $Jspitgdimage2->saveAsString();
$expected file_get_contents($tmpfname);
$t->check(strlen($binStr)." Byte",$binStr == $expected); 
[1.790 ms]
'45254 Byte'
Ok
Exif 240 $exifData $Jspitgdimage->getExif();
$ok is_array($exifData) || $exifData === false;
$t->check($exifData$ok); 
[0.001 ms]
array ( 'FileName' => 'imghRTDlp.jpg', 'FileDateTime' => 1745665903, 'FileSize' ..
Ok