humanemulator.net — справка.
Продукт, демо и покупка — на
хуманэмулятор.рф
|
Демо
|
Купить
|
API
|
лог изменений
get_image
get_image($src_path,$image_path,$x,$y,$width,$height); - получить новую картинку - как часть заданной доступна с версии 4.9.29Функция на вход принимает параметры:
После отработки функция возвращает результат своей работы в скрипт :
Пример использования
<?php // Scenario: Extract a portion of an image as a new image file $xhe_host = "localhost:7010"; if (!isset($path)){ // Path to the init.php file for connecting to the XHE API $path = "../../../Templates/init.php"; // Including init.php grants access to all classes and functionality for working with the XHE API require($path); } // Path to the source image $sourceImagePath = "images/screenshot.png"; // Path for the new image (portion of the source) $newImagePath = "images/portion.png"; // Make sure the source image file exists if (file_exists($sourceImagePath)) { echo "Source image found at: " . $sourceImagePath . "\n"; // Define the rectangular area to extract $x = 100; // X coordinate of the top-left corner $y = 150; // Y coordinate of the top-left corner $width = 300; // Width of the rectangular area $height = 200; // Height of the rectangular area echo "Extracting rectangular area:\n"; echo " X coordinate: " . $x . "\n"; echo " Y coordinate: " . $y . "\n"; echo " Width: " . $width . "\n"; echo " Height: " . $height . "\n"; // Extract the specified portion of the image $result = DOM::$image->get_image($sourceImagePath, $newImagePath, $x, $y, $width, $height); if ($result) { echo "Successfully extracted image portion to: " . $newImagePath . "\n"; // Verify the new image was created if (file_exists($newImagePath)) { echo "New image file exists and has been saved\n"; // Get file size of the new image $fileSize = filesize($newImagePath); echo "New image file size: " . $fileSize . " bytes\n"; } else { echo "Warning: New image file was not created\n"; } } else { echo "Failed to extract image portion\n"; } } else { echo "Source image file not found at: " . $sourceImagePath . "\n"; // For demonstration purposes echo "For this example to work, you would need an image file at: " . $sourceImagePath . "\n"; } // Quit the application WINDOW::$app->quit();
# Additional paths import sys sys.path.insert(0, '../../../Templates PY/') xhe_host = "127.0.0.1:7010" from xweb_human_emulator import * # начало echo("<hr><font color=blue>image.xxxxxxxxx</font><hr>") # 1 echo("1. Перейдем на полигон : ") echo(browser.navigate("https://rpa-bot.ru/wiki/poligon/image.html"),"<br>") # 2 echo("2. Скриншот картинки по src в файл : ") echo(image.screenshot_by_src("test\\test.bmp","https://rpa-bot.ru/wiki/poligon/screenshots/02.jpg"),"\n") # 3 echo("3. Вырежем картинку из файла : ") echo(image.get_image("test\\test.bmp","test\\part.jpg",126,72,40,33),"\n") # 4 echo("4. Покажем результат : ") echo(app.shell_execute("open","test\\part.jpg")) # конец echo("<hr><br>") # Quit app.quit()
#region using using System; using System.Diagnostics; using System.Collections.Generic; using System.Linq; using System.IO; using System.Text; using System.Threading; using XHE; using XHE.XHE_DOM; using XHE.XHE_System; using XHE.XHE_Window; using XHE.XHE_Web; #endregion class Program:XHEScript { static void Main(string[] args) { // init XHE server = "localhost:7010"; InitXHE(); // начало echo("<hr><font color=blue>image.get_image</font><hr>"); // 1 шаг echo("1. Перейдем на полигон : "); echo(browser.navigate("https://rpa-bot.ru/wiki/poligon/image.html")+"<br>"); // 2 шаг echo("2. Скриншот картинки по src в файл : "); echo(image.screenshot_by_src("test\\test.bmp","https://rpa-bot.ru/wiki/poligon/screenshots/02.jpg")+"\n"); // 3 шаг echo("3. Вырежем картинку из файла : "); echo(image.get_image("test\\test.bmp","test\\part.jpg",126,72,40,33)+"\n"); // 4 шаг echo("4. Покажем результат : "); echo (app.shell_execute("open","test\\part.jpg")); // конец echo("\n\n"); app.quit(); } }
// подключим функциональные объекты, если еще не подключен xhe_host="127.0.0.1:7010"; echo=require("../../../Templates JS/init.js"); // начало echo("<hr><font color=blue>image.get_image</font><hr>"); // 1 шаг echo("1. Перейдем на полигон : "); echo(browser.navigate("https://rpa-bot.ru/wiki/poligon/image.html")+"<br>"); // 2 шаг echo("2. Скриншот картинки по src в файл : "); echo(image.screenshot_by_src("test\\test.bmp","https://rpa-bot.ru/wiki/poligon/screenshots/02.jpg")+"\n"); // 3 шаг echo("3. Вырежем картинку из файла : "); echo(image.get_image("test\\test.bmp","test\\part.jpg",126,72,40,33)+"\n"); // 4 шаг echo("4. Покажем результат : "); echo(app.shell_execute("open","test\\part.jpg")); // конец echo("\n"); // Quit app.quit();
=============================================
Image Объекты DOM System Vision Web Window
=============================================
Если что-то непонятно или необходимо узнать или считаете что надо добавить по работе этой функции, пишите в комментарии или на наш форум.