#读取图片文件
$image=New-Object System.Drawing.Bitmap("C:\Users\Administrator\Desktop\广寒阁.bmp")
$cjname="test"
$Height = $image.Height;
$Width = $image.Width;
$tileWidth=256
$tileHeight=256
$colCount = [math]::Ceiling($Width / $tileWidth)
$rowCount = [math]::Ceiling($Height / $tileHeight)
[int]$resultrow=0
[int]$resultcol=0
$null=[math]::DivRem($Width,$tileWidth,[ref]$resultcol)
$null=[math]::DivRem($Height,$tileHeight,[ref]$resultrow)
for ($row = 0; $row -lt $rowCount; $row++)
{
if($row -eq $rowCount-1 -and $resultrow -ne 0){$tilesHeight=$resultrow}else{$tilesHeight=$tileHeight}
for ($col = 0; $col -lt $colCount; $col++)
{
if($col -eq $colCount-1 -and $resultcol -ne 0){$tilesWidth=$resultcol}else{$tilesWidth=$tileWidth}
#指定图片切割的坐标和大小
$left=$col*$tileWidth
$top&#
powershell 切割图片
最新推荐文章于 2024-03-12 16:26:47 发布