Powershell cut image,
# Read image files $ image = New-Object System. drawing. bitmap ("C: \ test \ xxx.bmp") $ cjname = "test" $ Height = $ image. height; $ Width = $ image. width; $ tileWidth = 256 $ tileHeight = 256 $ colCount = [math]: Ceiling ($ Width/$ tileWidth) $ rowCount = [math]: ceiling ($ Height/$ tileHeight) [int] $ result = 0for ($ row = 0; $ row-lt $ rowCount; $ row ++) {for ($ col = 0; $ col-lt $ colCount; $ col ++) {$ null = [math]: DivRem ($ Width, $ tileWidth, [ref] $ result) if ($ col-eq $ colCount-1-and $ result-ne 0) {$ tilesWidth = $ result} else {$ tilesWidth = $ tileWidth} $ null = [math]: DivRem ($ Height, $ tileHeight, [ref] $ result) if ($ row-eq $ rowCount-1-and $ result-ne 0) {$ tileHeight = $ result} else {$ tilesHeight = $ tileHeight} # specify the coordinates and size of the image cut $ part = New-Object System. drawing. rectangleF ($ col * $ tileWidth), ($ row * $ tileHeight), $ tilesWidth, $ tilesHeight) # clone an image $ s = $ image. clone ($ part, "Format24bppRgb") # specifies the format of color data for each pixel in the image http://msdn.microsoft.com/zh-cn/library/system.drawing.imaging.pixelformat (v = vs.110 ). aspx $ ss = "e: \ test \ $ cjname' _ tile _ $ row '_ $ col. jpg "# Save the file $ s. save ($ ss, "Jpeg") # specify the image file format http://msdn.microsoft.com/zh-cn/library/system.drawing.imaging.imageformat (v = vs.110 ). aspx $ s. dispose ()}}