我很感激你能帮我做些什么。
我刚刚发现有一个工具'ImageMagick‘可以命令行自动调整图像大小。基于这些知识,我认为这样做更明智:
文件夹结构:
中的
当我将“X”文件夹数(每个文件夹包含“X”图片)放入“导入”时,我想:
*。假设在“导出”中的第一个'X‘文件夹中复制了10个图片……它看起来像- 1a,1b,2a,2b,3a,3b . 10a,10b
当再次完成第一个'X‘folder...start,直到它到达'X’文件夹的末尾‘导入’。
示例#:这只是一个假设,文件和文件夹的名称和数量我们没有!
文件夹结构:
测试->子文件夹->导入,export
1. Resize all pictures in 'C:\TEST\import\f1' to 'C:\TEST\export\f1\1a'
2. Resize all pictures in 'C:\TEST\import\f1' to 'C:\TEST\export\f1\1b'
3. Resize all pictures in 'C:\TEST\import\e7' to 'C:\TEST\export\e7\1a'
4. Resize all pictures in 'C:\TEST\import\e7' to 'C:\TEST\export\e7\1b'
5. Resize all pictures in 'C:\TEST\import\DD' to 'C:\TEST\export\DD\1a'
6. Resize all pictures in 'C:\TEST\import\DD' to 'C:\TEST\export\DD\1b'
命令行中调整大小的
ImageMagick语法:
mogrify -resize 400x300源文件
mogrify -resize 400x300 C:\picture_name.jpg
我在他们的网站http://www.imagemagick.org/discourse-server/viewtopic.php?f=1&t=16486上找到了批处理脚本,也许可以帮上忙。
发布于 2012-02-08 19:08:50
好的。下面是如何编写一个批处理脚本来完成您需要做的事情(在Python中):将它保存为runMogrify.py
import os
import string
import fnmatch
source = "c:\\TEST\\import"
target = "c:\\TEST\\export"
def mogrify(parmSource, parmTarget):
mkdirList = []
copyList = []
mogrifyList = []
mkdirList.append('mkdir "' + parmTarget + '"')
for dirpath, dirnames, filenames in os.walk (parmSource):
# print dirpath, dirnames, filenames
for (index,file) in enumerate(sorted(filenames)):
if fnmatch.fnmatch(file.lower(), '*.jpg') or \
fnmatch.fnmatch(file.lower(), '*.gif') or \
fnmatch.fnmatch(file.lower(), '*.bmp'):
sourceFDirPathFile = dirpath + "\\" + file
targetFDirPath = os.path.join (parmTarget, dirpath[1+len (parmSource):])
targetADirPathFile = targetFDirPath + "\\" + str(index+1) + "a" + os.path.splitext(file)[1]
targetBDirPathFile = targetFDirPath + "\\" + str(index+1) + "b" + os.path.splitext(file)[1]
if 'mkdir "' + targetFDirPath + '"' not in mkdirList:
mkdirList.append('mkdir "' + targetFDirPath + '"')
copyList.append('copy "' + sourceFDirPathFile + '" "' + targetADirPathFile + '"')
copyList.append('copy "' + sourceFDirPathFile + '" "' + targetBDirPathFile + '"')
mogrifyList.append('mogrify -resize 400x300 "' + targetADirPathFile + '"')
mogrifyList.append('mogrify -resize 200x150 "' + targetBDirPathFile + '"')
return mkdirList, copyList, mogrifyList
def main():
mkdirList, copyList, mogrifyList = mogrify(source, target)
f = open('RUNMOGRIFY.BAT', 'w')
f.writelines( list("%s\n" % item for item in mkdirList ) )
f.writelines( list("%s\n" % item for item in copyList ) )
f.writelines( list("%s\n" % item for item in mogrifyList) )
f.close()
if __name__=="__main__": main()在我运行上面的Python之后,下面是生成的批处理文件(RUNMOGRIFY.BAT)
在与您的目录类似的测试目录上:
mkdir "c:\TEST\export"
mkdir "c:\TEST\export\folder1"
mkdir "c:\TEST\export\folder2"
mkdir "c:\TEST\export\folder3"
copy "c:\TEST\import\folder1\a.jpg" "c:\TEST\export\folder1\1a.jpg"
copy "c:\TEST\import\folder1\a.jpg" "c:\TEST\export\folder1\1b.jpg"
copy "c:\TEST\import\folder1\b.jpg" "c:\TEST\export\folder1\2a.jpg"
copy "c:\TEST\import\folder1\b.jpg" "c:\TEST\export\folder1\2b.jpg"
copy "c:\TEST\import\folder1\c.jpg" "c:\TEST\export\folder1\3a.jpg"
copy "c:\TEST\import\folder1\c.jpg" "c:\TEST\export\folder1\3b.jpg"
copy "c:\TEST\import\folder2\a.jpg" "c:\TEST\export\folder2\1a.jpg"
copy "c:\TEST\import\folder2\a.jpg" "c:\TEST\export\folder2\1b.jpg"
copy "c:\TEST\import\folder2\b.jpg" "c:\TEST\export\folder2\2a.jpg"
copy "c:\TEST\import\folder2\b.jpg" "c:\TEST\export\folder2\2b.jpg"
copy "c:\TEST\import\folder2\c.jpg" "c:\TEST\export\folder2\3a.jpg"
copy "c:\TEST\import\folder2\c.jpg" "c:\TEST\export\folder2\3b.jpg"
copy "c:\TEST\import\folder3\a.jpg" "c:\TEST\export\folder3\1a.jpg"
copy "c:\TEST\import\folder3\a.jpg" "c:\TEST\export\folder3\1b.jpg"
copy "c:\TEST\import\folder3\b.jpg" "c:\TEST\export\folder3\2a.jpg"
copy "c:\TEST\import\folder3\b.jpg" "c:\TEST\export\folder3\2b.jpg"
copy "c:\TEST\import\folder3\c.jpg" "c:\TEST\export\folder3\3a.jpg"
copy "c:\TEST\import\folder3\c.jpg" "c:\TEST\export\folder3\3b.jpg"
mogrify -resize 400x300 "c:\TEST\export\folder1\1a.jpg"
mogrify -resize 200x150 "c:\TEST\export\folder1\1b.jpg"
mogrify -resize 400x300 "c:\TEST\export\folder1\2a.jpg"
mogrify -resize 200x150 "c:\TEST\export\folder1\2b.jpg"
mogrify -resize 400x300 "c:\TEST\export\folder1\3a.jpg"
mogrify -resize 200x150 "c:\TEST\export\folder1\3b.jpg"
mogrify -resize 400x300 "c:\TEST\export\folder2\1a.jpg"
mogrify -resize 200x150 "c:\TEST\export\folder2\1b.jpg"
mogrify -resize 400x300 "c:\TEST\export\folder2\2a.jpg"
mogrify -resize 200x150 "c:\TEST\export\folder2\2b.jpg"
mogrify -resize 400x300 "c:\TEST\export\folder2\3a.jpg"
mogrify -resize 200x150 "c:\TEST\export\folder2\3b.jpg"
mogrify -resize 400x300 "c:\TEST\export\folder3\1a.jpg"
mogrify -resize 200x150 "c:\TEST\export\folder3\1b.jpg"
mogrify -resize 400x300 "c:\TEST\export\folder3\2a.jpg"
mogrify -resize 200x150 "c:\TEST\export\folder3\2b.jpg"
mogrify -resize 400x300 "c:\TEST\export\folder3\3a.jpg"
mogrify -resize 200x150 "c:\TEST\export\folder3\3b.jpg"https://stackoverflow.com/questions/9186887
复制相似问题