2012-05-23 32 views
0

我使用ImageMagick的对图像,如调整,降低质量执行命令行操作等太多的图像缩小在批处理文件使用ImageMagick

不过,我碰到的这个脚本一个问题:

SETLOCAL ENABLEDELAYEDEXPANSION 
@echo off 
REM Make the Modified folder, to store resized images. 
if not exist %CD%\Mod MKDIR %CD%\Mod 

REM loop through all files in working directory with extensions of .bin 
for /r %CD% %%G in (*.bin) do ( 
    set FILENAME=%%~nG 

    echo !FILENAME!.bin conversion beginning... 
    echo Beginning conversions... 
    echo Convert to TIF 

    REM rename the bin file with a .TIF extension. 
    copy !FILENAME!.bin !FILENAME!.tif 
    echo resizing image.... 
    REM convert the tif and resize it to 25%. This is where it reduces to almost nothing! 
    convert !FILENAME!.tif -resize 25% !FILENAME!.tif 
    echo Renaming file... 
    REM rename file to say it had been modified 
    ren !FILENAME!.tif !FILENAME!-mod.tif 
    echo Copying file... 
    REM copy the file to the Mod directory. 
    copy /y !FILENAME!-mod.tif %CD%\Mod 
    echo Cleaning up... 
    REM cleanup. 
    DEL !FILENAME!-mod.tif 
    echo Moving on to next file... 

) 

如果我运行从命令行调整图像大小的命令,它可以正常工作,并将图像缩小到估计大小。在脚本中,它减小到非常小的尺寸,我们正在讨论从大约2500x5000降到25x25,或类似的东西。这很奇怪,因为我正在执行完全相同的陈述,尽管方式不同。

我原本以为它是for循环的代表,但我通过它,在我去的时候暂停,并且它调整了一次执行的大小,确保它不是for循环不断调整图像大小的25倍直到它太小而无法继续。

为什么它缩小得如此之小,我该如何修复它?

编辑1:它转换bin文件的原因是因为所有BIN文件实际上都是TIF文件,无论出于何种原因,这些文件都使用bin扩展名重命名。事实上,它们是图像。

回答

1

我猜你需要与其他%逃出%,使25%变成25 %%

+0

+1,我是在提供相同的答案:-) – dbenham

+0

的过程可能是最糟糕的*杜*我今天有过的时刻。谢谢,那就是它! – valkn0t