代码如下。遇到的问题是,我有一个图片,应该是A2尺寸,被判断为了A3,请问应该怎么修改?图片的详细信息如下。- @set @n=0/* & echo off
- cd /d E:\test\
- dir /a-d /b /s *.tif *.jpg *.png *.jpeg | cscript -nologo -e:jscript "%~f0"
- pause & exit /b */
-
- var arr = [0, 0, 0, 0, 0, 0];
- var ssh = new ActiveXObject('Shell.Application');
- var fd = ssh.NameSpace(0x00);
-
- var checkSize = function(width, height){
- if(width>=129 || height>=129){
- arr[0] += 1;
- return 'A0+'
- }else if((width>=118.9 && width<129) || (height>=118.9 && height<129)){
- arr[1] += 1;
- return 'A0'
- }else if((width>=84.1 && width<118.9) || (height>=84.1 && height<118.9)){
- arr[2] += 1;
- return 'A1'
- }else if((width>=59.4 && width<84.1) || (height>=59.4 && height<84.1)){
- arr[3] += 1;
- return 'A2'
- }else if((width>=42 && width<59.4) || (height>=42 && height<59.4)){
- arr[4] += 1;
- return 'A3'
- }else {
- arr[5] += 1;
- return 'A4'
- }
- }
-
- for(var i=0; i<300; i++) {
- if(fd.GetDetailsOf(null, i) == '宽度') {
- var n1 = i;
- }else if(fd.GetDetailsOf(null, i) == '高度') {
- var n2 = i;
- }else if(/^水平分[辨辩]率$/.test(fd.GetDetailsOf(null, i))) {
- var n3 = i;
- }else if(/^垂直分[辨辩]率$/.test(fd.GetDetailsOf(null, i))) {
- var n4 = i;
- }
- }
-
- while(!WSH.StdIn.AtEndOfStream){
- var file = WSH.StdIn.ReadLine();
- var name = file.replace(/.+\\(.+)$/, '$1');
- var fd = ssh.NameSpace( file.replace(/(.+)\\.+$/, '$1') );
- var w = fd.GetDetailsOf(fd.ParseName(name), n1).match(/\d+/)[0]; //宽度
- var h = fd.GetDetailsOf(fd.ParseName(name), n2).match(/\d+/)[0]; //高度
- var hr = fd.GetDetailsOf(fd.ParseName(name), n3).match(/\d+/)[0]; //水平刷新率
- var vr = fd.GetDetailsOf(fd.ParseName(name), n4).match(/\d+/)[0]; //垂直刷新率
- var width = (w / hr * 2.54).toFixed(1); height = (h / vr * 2.54).toFixed(1);
- var size = checkSize(width, height);
- WSH.Echo(name + ' ' + width + 'x' + height + ' ' + size);
- }
-
- var s = 'A0+共' + arr[0] + '张,A0共' + arr[1] + '张,A1共' + arr[2] + '张,';
- s += 'A2共' + arr[3] + '张,A3共' + arr[4] + '张,A4共' + arr[5] + '张\r\n';
- s += '折合A4共' + (arr[0]*32+arr[1]*16+arr[2]*8+arr[3]*4+arr[4]*2+arr[5]) + '张'
-
- WSH.Echo(s)
复制代码
|