# How to use rgb_int_diff method of pts_image class

Best Phoronix-test-suite code snippet using pts_image.rgb_int_diff

pts_image.php

Source:pts_image.php

`...72 \$rgb = imagecolorat(\$img, \$x, \$y);73 // R, G, B74 return array((\$rgb >> 16) & 0xFF, (\$rgb >> 8) & 0xFF, \$rgb & 0xFF);75 }76 public static function rgb_int_diff(\$rgb1, \$rgb2)77 {78 return abs(array_sum(\$rgb1) - array_sum(\$rgb2));79 }80 public static function gd_image_delta_composite(&\$base_img, &\$compare_img, \$only_return_changes = true)81 {82 \$composite = array();83 for(\$x = 0; \$x < imagesx(\$base_img); \$x++)84 {85 for(\$y = 0; \$y < imagesy(\$base_img); \$y++)86 {87 \$base_rgb = imagecolorat(\$base_img, \$x, \$y);88 \$compare_rgb = imagecolorat(\$compare_img, \$x, \$y);89 \$diff_rgb = abs(\$base_rgb - \$compare_rgb);90 if(\$only_return_changes == false || \$diff_rgb != 0)91 {92 \$composite[\$x][\$y] = \$diff_rgb;93 }94 }95 }96 return \$composite;97 }98 public static function color_pixel_delta(&\$base_img, &\$compare_img, &\$x, &\$y)99 {100 \$color = false; // for now we set to true when it should change, but ultimately should return a color101 \$check_points = array(102 array(\$x + 1, \$y),103 array(\$x - 1, \$y),104 array(\$x, \$y + 1),105 array(\$x, \$y - 1)106 );107 foreach(\$check_points as \$point_r)108 {109 if(pts_image::rgb_int_diff(pts_image::rgb_gd_color_at(\$base_img, \$point_r[0], \$point_r[1]), pts_image::rgb_gd_color_at(\$compare_img, \$point_r[0], \$point_r[1])) > 12)110 {111 \$color = array(\$point_r[0], \$point_r[1]);112 break;113 }114 }115 return \$color;116 }117 public static function compress_png_image(\$png_file, \$compression_level = 8)118 {119 if(function_exists('imagecreatefrompng'))120 {121 \$img = imagecreatefrompng(\$png_file);122 if(\$img)123 {...`

rgb_int_diff

Using AI Code Generation

`1require_once("pts_image.php");2\$pts_image = new pts_image();3\$pts_image->rgb_int_diff(0,0,0,255,255,255);4\$pts_image->rgb_int_diff(255,255,255,0,0,0);5\$pts_image->rgb_int_diff(0,0,0,0,0,0);6\$pts_image->rgb_int_diff(255,255,255,255,255,255);7\$pts_image->rgb_int_diff(255,0,0,0,255,0);8\$pts_image->rgb_int_diff(0,255,0,0,0,255);9\$pts_image->rgb_int_diff(0,0,255,255,0,0);`

rgb_int_diff

Using AI Code Generation

`1include("pts_image.php");2\$source = "images/1.jpg";3\$target = "images/2.jpg";4\$source_image = new pts_image(\$source);5\$target_image = new pts_image(\$target);6\$source_image->load_image();7\$target_image->load_image();8\$diff = \$source_image->rgb_int_diff(\$target_image);9echo "Difference = ".\$diff;`

rgb_int_diff

Using AI Code Generation

`1include('pts_image.php');2\$im1 = new pts_image();3\$im2 = new pts_image();4\$im1->load('1.jpg');5\$im2->load('2.jpg');6\$diff = \$im1->rgb_int_diff(\$im2);7echo \$diff;8include('pts_image.php');9\$im1 = new pts_image();10\$im2 = new pts_image();11\$im1->load('1.jpg');12\$im2->load('2.jpg');13\$diff = \$im1->rgb_int_diff(\$im2);14echo \$diff;15include('pts_image.php');16\$im1 = new pts_image();17\$im2 = new pts_image();18\$im1->load('1.jpg');19\$im2->load('2.jpg');20\$diff = \$im1->rgb_int_diff(\$im2);21echo \$diff;22include('pts_image.php');23\$im1 = new pts_image();24\$im2 = new pts_image();25\$im1->load('1.jpg');26\$im2->load('2.jpg');27\$diff = \$im1->rgb_int_diff(\$im2);28echo \$diff;`

rgb_int_diff

Using AI Code Generation

`1\$impath1 = "images/1.jpg";2\$impath2 = "images/2.jpg";3\$im1 = new pts_image(\$impath1);4\$im2 = new pts_image(\$impath2);5\$diff = \$im1->rgb_int_diff(\$im2);6echo "The difference between the 2 images is: ".\$diff;`

rgb_int_diff

Using AI Code Generation

`1include 'pts_image.php';2include 'pts_image.php';3\$obj=new pts_image();4\$diff=\$obj->rgb_int_diff("2.jpg","3.jpg");5\$myfile = fopen("rgb_int_diff.txt", "w") or die("Unable to open file!");6fwrite(\$myfile, \$diff);7fwrite(\$myfile, "\n");8fwrite(\$myfile, "2.jpg");9fwrite(\$myfile, "\n");10fwrite(\$myfile, "3.jpg");11fwrite(\$myfile, "\n");12fclose(\$myfile);`

rgb_int_diff

Using AI Code Generation

`1include_once("../pts_image.class.php");2\$im1 = new pts_image();3\$im2 = new pts_image();4\$im1->load_from_file("1.jpg");5\$im2->load_from_file("2.jpg");6\$im3 = \$im1->rgb_int_diff(\$im2);7\$im3->save_to_file("diff.jpg");`

rgb_int_diff

Using AI Code Generation

`1require_once('pts_image.php');2\$img1 = new pts_image();3\$img1->load_image('2.jpg');4\$img2 = new pts_image();5\$img2->load_image('3.jpg');6\$img1->rgb_int_diff(\$img2)->save_image('diff.png');7\$img1->rgb_to_gray();8\$img1->rgb_int_diff(\$img2)->save_image('diff2.png');`

## Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

## LambdaTest Learning Hubs:

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

## Run Phoronix-test-suite automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

## Most used method in pts_image

### Trigger rgb_int_diff code on LambdaTest Cloud Grid

Execute automation tests with rgb_int_diff on a cloud-based Grid of 3000+ real browsers and operating systems for both web and mobile applications.