humanemulator.net — справка.
Продукт, демо и покупка — на
хуманэмулятор.рф
|
Демо
|
Купить
|
API
|
Changelog
rewidth
rewidth($inpath,$outpath,$width); - Изменить ширину картинки (с сохранением пропорций)Функция на вход принимает параметры:
После выполнения функции возвращаемое значение будет равно одному из двух :
Пример использования
<?php // Scenario: Change the width of an image while maintaining aspect ratio $xhe_host = getenv("RPABOT_HOST_URL"); 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/original_image.png"; // Make sure the source image file exists if (file_exists($sourceImagePath)) { echo "Source image found at: " . $sourceImagePath . "\n"; // Example 1: Change width to 300 pixels (height will be adjusted automatically) $rewidthImagePath1 = "images/rewidth_300.png"; $newWidth1 = 300; echo "Changing image width to " . $newWidth1 . " pixels...\n"; $result1 = DOM::$image->rewidth($sourceImagePath, $rewidthImagePath1, $newWidth1); if ($result1) { echo "Successfully changed image width to " . $newWidth1 . " pixels\n"; echo "Rewidthed image saved to: " . $rewidthImagePath1 . "\n"; // Verify the new image was created if (file_exists($rewidthImagePath1)) { echo "Rewidthed image file exists and has been saved\n"; // Get file size of the new image $fileSize1 = filesize($rewidthImagePath1); echo "Rewidthed image file size: " . $fileSize1 . " bytes\n"; } else { echo "Warning: Rewidthed image file was not created\n"; } } else { echo "Failed to change image width to " . $newWidth1 . " pixels\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:3035" from xweb_human_emulator import * # начало echo("<hr><font color=blue>image.xxxxxxxxx</font><hr>") # 1 echo("1. Уменьшим картинку до 300 пикселей по ширине : "); echo(image.rewidth("test\\test.jpg","test\\test_rewidth.jpg", 300),"\n"); # 2 echo("2. Покажем результат : "); echo(app.shell_execute("open","test\\test_rewidth.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 = Environment.GetEnvironmentVariable("RPABOT_HOST_URL"); InitXHE(); // начало echo("<hr><font color=blue>image.add_image</font><hr>"); // 1 echo("1. Уменьшим картинку до 300 пикселей по ширине : "); echo(image.rewidth("test\\test.jpg","test\\test_rewidth.jpg", 300)+"\n"); // 2 echo("2. Покажем результат : "); echo(app.shell_execute("open","test\\test_rewidth.jpg")); // конец echo("\n\n"); app.quit(); } }
// подключим функциональные объекты, если еще не подключен xhe_host="127.0.0.1:3035"; echo=require("../../../Templates JS/init.js"); // начало echo("<hr><font color=blue>image.add_image</font><hr>"); // 1 echo("1. Уменьшим картинку до 300 пикселей по ширине : "); echo(image.rewidth("test\\test.jpg","test\\test_rewidth.jpg", 300)+"\n"); // 2 echo("2. Покажем результат : "); echo(app.shell_execute("open","test\\test_rewidth.jpg")); // конец echo("\n"); // Quit app.quit();
=============================================
Image Объекты DOM System Vision Web Window
=============================================
Если что-то непонятно или необходимо узнать или считаете что надо добавить по работе этой функции, пишите в комментарии или на наш форум.