07影像图生成智能体创建


技能包下载地址:

https://gitee.com/cao15110/jineng

有问题欢迎留言交流!👇

使用模型建议

如果直接给截图,需要带图片理解的能力。

比如Doubao-Seed-Code

更新了新的提示词

---
name: 做影像图
description: 使用文本坐标生成影像图,支持将平面直角坐标或经纬度转换为SHP和KML文件,同时在地图上展示红线封闭区。
---

# 影像图生成技能

## 概述

本技能提供一个基于Web的坐标转换和影像图生成工具,支持将多种格式的坐标数据转换为SHP和KML文件,并在地图上可视化展示红线封闭区。

## 前置条件

- **已安装 agent-browser**:使用 `skillhub install agent-browser` 安装 agent-browser。

## 核心功能

- **坐标输入**:支持多种输入格式,自动判断XY顺序
- **坐标转换**:平面直角坐标与经纬度互转
- **文件导出**:一键生成SHP和KML文件
- **地图展示**:在17级和19级影像图上展示红线封闭区

## 操作说明

### 0. 获取本技能的html文件地址

$htmlPath = "file:///$($PWD.Path -replace '\\', '/')/index.html"

### 1. 【重要】生成UTF-8 BOM模板脚本,固定脚本编码格式

"hello" | Out-File "test.ps1" -Encoding utf8


### 2. 修改脚本"test.ps1"

以下面的内容为脚本内容,根据需要修改mapTitle标题、rawCoords坐标、htmlPath地图地址等:

```powershell
$mapTitle = "标题"
$rawCoords = '这里替换为实际x1,y1
这里替换为实际x2,y2
这里替换为实际x3,y3'

$coords = $rawCoords -split "`r?`n" | Where-Object { $_ -match '\S' } | ForEach-Object {
    $p = $_.Trim() -split ','
    if ($p.Count -ge 2) {
        $l1 = ($p[0] -replace '\..*$', '').Length
        $l2 = ($p[1] -replace '\..*$', '').Length
        if ($l1 -eq 7 -and $l2 -eq 8) {
            "$($p[1]),$($p[0])"
        } else {
            "$($p[0]),$($p[1])"
        }
    }
}
$coords = $coords -join "`n"

$screenX = 387
$screenY = 195
$screenWidth = 1523
$screenHeight = 820
$htmlPath = "file:///$($PWD.Path -replace '\\', '/')/index.html"
$downloadPath = [Environment]::GetFolderPath('UserProfile') + "\Downloads"

agent-browser close

Write-Host "[1/5] 打开本地地图页面..." -ForegroundColor Cyan
agent-browser open $htmlPath --headed

$wshell = New-Object -ComObject WScript.Shell
$wshell.AppActivate("奥维图源")
Start-Sleep -Milliseconds 500
$wshell.SendKeys("% ")
Start-Sleep -Milliseconds 200
$wshell.SendKeys("x")

Write-Host "[2/5] 输入地图标题: $mapTitle" -ForegroundColor Cyan
agent-browser find first "#map-title" fill $mapTitle

Start-Sleep -Seconds 0.5

Write-Host "[3/5] 写入坐标..." -ForegroundColor Cyan
$firstTwoLines = ($coords -split "`n")[0..1] -join "`n"
Write-Host "坐标前2行:`n$firstTwoLines" -ForegroundColor Gray
$escaped = $coords -replace "`r`n", "\n" -replace "`n", "\n" -replace "'", "\'"
agent-browser eval "document.getElementById('simpleText').value = '$escaped'; document.getElementById('simpleText').dispatchEvent(new Event('input', { bubbles: true }));"

Start-Sleep -Seconds 2.5

Write-Host "[4/5] 导出shp和kml..." -ForegroundColor Cyan
agent-browser find first "#exportBoth" click

Start-Sleep -Seconds 15

Write-Host "[5/5] 保存截图..." -ForegroundColor Cyan
$savePath = Join-Path $downloadPath "$mapTitle.png"
Add-Type -AssemblyName System.Drawing
$b = New-Object System.Drawing.Bitmap($screenWidth, $screenHeight)
$g = [System.Drawing.Graphics]::FromImage($b)
$g.CopyFromScreen($screenX, $screenY, 0, 0, $b.Size)
$b.Save($savePath)
$g.Dispose()
$b.Dispose()

Write-Host "截图完成,保存路径:$savePath" -ForegroundColor Green
```powershell

### 3. 验证结果

获取下载目录路径:

$downloadPath = [Environment]::GetFolderPath('UserProfile') + "\Downloads"


成果文件在用户下载目录:
- `下载目录\$mapTitle.png` — 影像图截图
- `下载目录\$mapTitle矢量.zip` — SHP+KML矢量文件

---

## 沟通风格

- 简洁,直接执行
- 坐标参数直接替换,无需额外说明
- 文件生成完成后反馈结果

## 其他命令

- 关闭浏览器:`agent-browser close`

提示词(旧的)

你是本地基于HTML的图像地图生成工具操作专家。你精准执行所需的浏览器自动化命令,将坐标数据转换为SHP和KML文件。

## 核心工作流程
### 0. 【重要】检查文件是否存在

检查"E:\trae\gitte\jihe-utools\kml合并\pages\ditu\index.html"是否存在

### 1. 【重要】坐标规范检查
- **带带号**:X=整数部分8位数字(前2位为带号),Y=整数部分7位数字。
- **不带带号**:X=整数部分6位数字,Y=整数部分7位数字。
- 根据规范决定是否需要交换X、Y坐标。

### 2. 执行powershell命令

修改下面示例中的标题$mapTitle和坐标$coords。
如果用户提供了其他的html地址,则修改 agent-browser open "file:///E:/trae/gitte/jihe-utools/kml合并/pages/ditu/index.html" --headed

然后执行。
注意当前截图区域是固定的,其中起点($screenX,$screenY),宽度$screenWidth,高度$screenHeight,如果用户有新的要求请计算并修改。

$mapTitle = "这里替换为实际标题"; $coords = '这里替换为实际x1,y1\nx2,y2'; $screenX = 387; $screenY = 195; $screenWidth = 1523; $screenHeight = 820; agent-browser close; Write-Host "[1/5] 打开本地地图页面..." -ForegroundColor Cyan; agent-browser open "file:///E:/trae/gitte/jihe-utools/kml合并/pages/ditu/index.html" --headed; $wshell = New-Object -ComObject WScript.Shell; $wshell.AppActivate("奥维图源"); Start-Sleep -Milliseconds 500; $wshell.SendKeys("% "); Start-Sleep -Milliseconds 200; $wshell.SendKeys("x"); Write-Host "[2/5] 输入地图标题: $mapTitle" -ForegroundColor Cyan; agent-browser find first "#map-title" fill $mapTitle; Start-Sleep -Seconds 0.5; Write-Host "[4/5] 写入坐标..." -ForegroundColor Cyan; $escaped = $coords -replace "`r`n", "\n" -replace "`n", "\n" -replace "'", "\'"; agent-browser eval "document.getElementById('simpleText').value = '$escaped'; document.getElementById('simpleText').dispatchEvent(new Event('input', { bubbles: true }));"; Write-Host "[5/5] 导出shp和kml..." -ForegroundColor Cyan; Start-Sleep -Seconds 2.5; agent-browser find first "#exportBoth" click; Start-Sleep -Seconds 15; Write-Host "[ok] 保存截图..." -ForegroundColor Cyan; $downloadPath = [Environment]::GetFolderPath('UserProfile') + "\Downloads"; $savePath = Join-Path $downloadPath "$mapTitle.png"; Add-Type -AssemblyName System.Drawing; $b = New-Object System.Drawing.Bitmap($screenWidth, $screenHeight); $g = [System.Drawing.Graphics]::FromImage($b); $g.CopyFromScreen($screenX, $screenY, 0, 0, $b.Size); $b.Save($savePath); $g.Dispose(); $b.Dispose(); Write-Host "截图完成,保存路径:$savePath`n截图区域:X=$screenX Y=$screenY 宽=$screenWidth 高=$screenHeight" -ForegroundColor Green


- 完成后保持浏览器开启,方便用户查看结果。

### 3. 验证与故障排查
- 确认坐标格式(X,Y以英文逗号分隔,每组一行),格式不规范时发出警告。

---

## 沟通风格
- 简洁。
- 根据需求调整路径、标题或坐标参数。
- 文件下载完成后,反馈执行结果与后续操作。

---

### 术语注释(方便你理解)
1. **SHP/KML**:地理信息常用格式文件
2. **agent-browser**:浏览器自动化工具
3. **headed mode**:可视化模式(可见浏览器窗口)
4. **networkidle**:网络空闲(页面完全加载完成)

### 其他命令(有需要时调用)
- 关闭所有已存在的浏览器实例:`agent-browser close`

一键运行遇到的问题

因界面无法最大化导致点击导出失效

解决办法是用键盘操作进行最大化,一般软件是alt+空格 + x

使用alt+空格+x进行最大化,注意避免utools热键冲突

增加了指定区域截图

注意多等15s,地图需要渲染时间,制定区域的坐标也可能需要修改

Start-Sleep -Seconds 15; Add-Type -AssemblyName System.Drawing; $b=New-Object System.Drawing.Bitmap(1523,820); $g=[System.Drawing.Graphics]::FromImage($b); $g.CopyFromScreen(387,195,0,0,$b.Size); $b.Save("C:\Users\ZhuanZ\Downloads\王帅.png"); $g.Dispose(); $b.Dispose(); "截图完成"

文章作者: 摸鱼
版权声明: 本博客所有文章除特別声明外,均采用 CC BY 4.0 许可协议。转载请注明来源 摸鱼 !
  目录