请各位推荐一款windows平台的图片分割软件,期望功能包括:
- 输入切割份数,自动将一张大图片分割成均匀大小的若干份
- 最好绿色软件
请各位推荐一款windows平台的图片分割软件,期望功能包括:
这个 PS 的切片做起来相当容易,但是其他工具能够这么灵活地好像还没见过
imagemagick?
没有现成的,就用ahk的gdip自己写了个。
厉害了,分享出来好不好?
我帮你整理一点格式,感谢分享!
自己写的,比较简单
#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)
}