humanemulator.net — справка. Продукт, демо и покупка — на хуманэмулятор.рф | Демо | Купить | API | лог изменений

add_image

add_image($src_path,$image_path,$side="right"); - добавить картинку к заданной доступна с версии 4.9.29

Функция на вход принимает параметры:

  • $src_path – путь к исходной картинки (может быть относительным)
  • $image_path – путь к добавляемой картинке(может быть относительным)
  • $side – с какой стороны надо добавить картинку ("right" - справа "bottom" - снизу)

    После отработки функция возвращает результат своей работы в скрипт :
  • true – успешно выполнили (boolean)
  • false – операция не произведена (boolean)

    Пример использования
    <?php
    // Scenario: Add one image to another (combine images side by side)
    $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 (base image)
    $sourceImagePath = "images/logo.png";
    
    // Path to the image to add
    $imageToAddPath = "images/icon.png";
    
    // Make sure both source image files exist
    if (file_exists($sourceImagePath) && file_exists($imageToAddPath)) {
        echo "Both source images found\n";
        echo "Base image: " . $sourceImagePath . "\n";
        echo "Image to add: " . $imageToAddPath . "\n";
        
        // Example 1: Add the image to the right of the base image
        echo "Adding image to the right of the base image...\n";
        $result1 = DOM::$image->add_image($sourceImagePath, $imageToAddPath, "right");
        
        if ($result1) {
            echo "Successfully combined images (right side)\n";
            echo "Result saved to in source image file: " . $sourceImagePath . "\n";
        } else {
            echo "Failed to combine images (right side)\n";
        }
        
        // Example 2: Add the image to the left of the base image
        echo "\nAdding image to the left of the base image...\n";
        $result2 = DOM::$image->add_image($sourceImagePath, $imageToAddPath, "left");
        
        if ($result2) {
            echo "Successfully combined images (left side)\n";
            echo "Result saved to in source image file: " . $sourceImagePath . "\n";
        } else {
            echo "Failed to combine images (left side)\n";
        }
        
        // Example 3: Add the image to the bottom of the base image
        echo "\nAdding image to the bottom of the base image...\n";
        $result3 = DOM::$image->add_image($sourceImagePath, $imageToAddPath, "bottom");
        
        if ($result3) {
            echo "Successfully combined images (bottom)\n";
            echo "Result saved to in source image file: " . $sourceImagePath . "\n";
        } else {
            echo "Failed to combine images (bottom)\n";
        }
        
        // Example 4: Add the image to the top of the base image
        echo "\nAdding image to the top of the base image...\n";
        $result4 = DOM::$image->add_image($sourceImagePath, $imageToAddPath, "up");
        
        if ($result4) {
            echo "Successfully combined images (top)\n";
            echo "Result saved to in source image file: " . $sourceImagePath . "\n";
        } else {
            echo "Failed to combine images (top)\n";
        }
    } else {
        echo "One or both source image files not found\n";
        
        // For demonstration purposes
        echo "For this example to work, you would need:\n";
        echo "- A base image file at: " . $sourceImagePath . "\n";
        echo "- An image to add at: " . $imageToAddPath . "\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.jpg","https://rpa-bot.ru/wiki/poligon/screenshots/02.jpg"),"\n")
    
    # 3 
    echo("3. Вырежем картинку из файла : ")
    echo(image.get_image("test\\test.jpg","test\\part.bmp",126,72,40,33),"\n")
    
    # 4 
    echo("4. Добавим картинку : ")
    echo(image.add_image("test\\test.jpg","test\\part.bmp","right"),"\n")
    
    # 5 
    echo("5. Покажем результат : ")
    echo(app.shell_execute("open","test\\test.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.add_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.jpg","https://rpa-bot.ru/wiki/poligon/screenshots/02.jpg")+"\n");
    
    			// 3 шаг
    			echo("3. Вырежем картинку из файла : ");
    			echo(image.get_image("test\\test.jpg","test\\part.bmp",126,72,40,33)+"\n");
    
    			// 4 шаг
    			echo("4. Добавим картинку : ");
    			echo(image.add_image("test\\test.jpg","test\\part.bmp","right")+"\n");
    
    			// 5 шаг
    			echo("5. Покажем результат : ");
    			echo(app.shell_execute("open","test\\test.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.add_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.jpg","https://rpa-bot.ru/wiki/poligon/screenshots/02.jpg")+"\n");
    
    // 3 шаг
    echo("3. Вырежем картинку из файла : ");
    echo(image.get_image("test\\test.jpg","test\\part.bmp",126,72,40,33)+"\n");
    
    // 4 шаг
    echo("4. Добавим картинку : ");
    echo(image.add_image("test\\test.jpg","test\\part.bmp","right")+"\n");
    
    // 5 шаг
    echo("5. Покажем результат : ");
    echo(app.shell_execute("open","test\\test.jpg"));
    
    // конец
    echo("\n");
    
    // Quit
    app.quit();

    =============================================
    Image    Объекты    DOM  System  Vision  Web  Window        
    =============================================
    Если что-то непонятно или необходимо узнать или считаете что надо добавить по работе этой функции, пишите в комментарии или на наш форум.