求一款图片分割软件【windows平台】

请各位推荐一款windows平台的图片分割软件,期望功能包括:

  1. 输入切割份数,自动将一张大图片分割成均匀大小的若干份
  2. 最好绿色软件

这个 PS 的切片做起来相当容易,但是其他工具能够这么灵活地好像还没见过

imagemagick?

没有现成的,就用ahk的gdip自己写了个。

厉害了,分享出来好不好?

我帮你整理一点格式,感谢分享!

自己写的,比较简单

  1. 需要 gdip .ahk 和 irfanview 的 i_view64.exe 放到同一个目录下
  2. 代码中的 xNum, yNum 分别是宽度、长度方向的分割数
  3. 代码中有两个分割函数,Cropper 和 FileCrop。前者需要依赖外部程序 i_view64;后者直接调用 gdip 实现,但在我电脑上有问题(跟 AHK 版本 ANSI 或者 Unicode 相关) 。如果你电脑上装的是 AHK ANSI 版本,直接用 FileCrop 函数就行。
#Include Gdip.ahk
F1::
ir_path:=A_ScriptDir "\i_view64.exe" ; path for IrfanView
IfNotExist %ir_path% 
{
	MsgBox IrfanView missing
	return
}
FileSelectFile, oldFile, 3, , Prompt, Picture(*.png;*.bmp;*.jpg)
if oldFile =  
{
    MsgBox, The user didn't select anything.
	return
}

SplitPath, oldFile , , OutDir, oldFileExt, oldFileNoExt
pToken := Gdip_Startup()
pBM := Gdip_CreateBitmapFromFile( oldFile )
;DllCall("gdiplus\GdipGetImageWidth", "uint", pBitmap, "uint*", Width)
oldFileWidth := Gdip_GetImageWidth(pBM)
oldFileHeight := Gdip_GetImageHeight(pBM)
xNum:=2
yNum:=1
Loop, %xNum%
{
	xIndex:=A_Index
	Loop, %yNum%
	{
		yIndex:=A_Index
		newFile:=OutDir . "\" . oldFileNoExt . "-" . xIndex . "-" . yIndex . "." . oldFileExt
		newWidth:=Ceil(oldFileWidth/xNum)
		newHeight:=Ceil(oldFileHeight/yNum)
		xStart:=(xIndex-1)*newWidth
		yStart:=(yIndex-1)*newHeight

		Cropper(oldFile,xStart,yStart,newWidth,newHeight,newFile)
	}
}
Gdip_Shutdown(pToken)
return
F11::Reload
Cropper(oldPicFile,x,y,width,height,newPicFile)
{
	global ir_path
	crop_area:="/crop=(" . x . chr(44) . y . chr(44) . width . chr(44) . height . chr(44) . "0)"
	ir_cmd:=ir_path . chr(32) . oldPicFile . chr(32) . crop_area . " /convert=" . newPicFile . "/cmdexit"
	RunWait,%ir_cmd%	
}


FileCrop(oldPicFile,x,y,width,height,newPicFile)
{
	SplitPath, oldPicFile,,, FileExt
	if (FileExt = "bmp")
		Format := 0x21808
	else
		Format := 0x26200A
	;pToken := Gdip_Startup()	
	pBitmapOld := Gdip_CreateBitmapFromFile(oldPicFile)	
	pBitmapNew := Gdip_CreateBitmap(width, height, Format)
	G := Gdip_GraphicsFromImage(pBitmapNew)
	Gdip_SetSmoothingMode(G, 4)
	Gdip_SetInterpolationMode(G, 7)
	pp:=Gdip_DrawImage(G, pBitmapOld, 0, 0, width, height,x,y,width, height)	
	Gdip_DisposeImage(pBitmapOld)
	pp:=Gdip_SaveBitmapToFile(pBitmapNew, newPicFile)
	MsgBox %pp% file save
	Gdip_DisposeImage(pBitmapNew)
	Gdip_DeleteGraphics(G)
}