- 帖子
- 47
- 积分
- 67
- 技术
- 0
- 捐助
- 0
- 注册时间
- 2022-3-18
|
回复 11# idwma
#@&cls&powershell "type '%~f0'|out-string|iex"&pause&exit
Add-Type -AssemblyName System.Drawing
$cp = New-Object CodeDom.Compiler.CompilerParameters
$cp.ReferencedAssemblies.Add([Reflection.Assembly]::GetAssembly([Drawing.Image]).Location) >$null
$cp.ReferencedAssemblies.Add([Reflection.Assembly]::GetAssembly([Linq.Enumerable]).Location) >$null
$cp.CompilerOptions ='/unsafe'
Add-Type -CompilerParameters $cp -TypeDefinition @'
using System;
using System.Drawing;
using System.Drawing.Imaging;
using System.Collections.Generic;
using System.Linq;
public class test
{
unsafe public static int main(string f)
{
Bitmap bitmap = new Bitmap(@f);
int width = bitmap.Width;
int height = bitmap.Height;
int h = height/2;
BitmapData bitmapData = bitmap.LockBits(new Rectangle(0, h, width, height-h), ImageLockMode.ReadOnly, PixelFormat.Format32bppArgb);
byte* p = (byte*)(IntPtr)bitmapData.Scan0;
Dictionary<int, int> b = new Dictionary<int, int>();
for (int i = 0; i < width * (height-h) * 4; i+=4)
{
int c = (p[i+3] << 24) | (p[i+2] << 16) | (p[i+1] << 8) | p;
b[c] = b.ContainsKey(c) ? b[c] + 1 : 1;
}
bitmap.UnlockBits(bitmapData);
var d = b.OrderBy(x => x.Value).Select(x => x.Value).ToArray();
return width*h/(d[d.Length-1]) < 30 ? 1 : 0;
}
}
'@
mkdir 123
dir *.jpg|%{if([test]::main($_.FullName)){move $_.fullname '123'}} |
|