一个文件夹中获取名称和所有影像尺寸 [英] Get name and dimensions of all images in a folder
问题描述
我如何得到所有图像的名称和尺寸的文件夹中?我有一个文件夹中超过50K的图像。我需要的所有图像文件的尺寸沿名单。 Windows 7的PC使用MediaInfo和Python安装。如果需要的话像ImageMagick的可以安装其他软件。
How do I get names and dimensions of all images in a folder? I have over 50k images in a folder. I need list of names along with dimensions of all image files. Windows 7 PC with Mediainfo and Python installed. Can install other software if needed like ImageMagick.
由渔业部编辑,以显示雷努卡如何提出正确的。
我在文件夹 C:\\ TEMP \\我的图片
及其子文件夹与名称超过50.000图像文件,比如
I have in folder C:\Temp\My Pictures
and its subfolders over 50.000 image files with names like
- 子文件夹1
- 我Photo1.jpg
- 另一个Photo.jpg
文件扩展支持是:JPG,JPEG,PNG,GIF,BMP
The file extensions to support are: JPG, JPEG, PNG, GIF, BMP
在想要得到与路径每个图像文件的名称到CSV文件中
C:\\ TEMP \\ ImageList.csv
与In want to get the name of each image file with path into a CSV file
C:\Temp\ImageList.csv
with:- 用双引号路径文件名
- 在像素的图像宽度
- 在像素的图像高度
分隔符应是逗号,即
,
CSV文件应该寻找例如上面的文件列表:
The CSV file should look for example for above file list:
"C:\Temp\My Pictures\Subfolder 1\My Photo1.jpg",800,600 "C:\Temp\My Pictures\OneMoreSubFolder\Another Photo.jpg",768,1024 "C:\Temp\My Pictures\PNG image.png",48,36
在code我至今是:
The code I have so far is:
rem Here should be your code. You should have already searched in WWW rem by yourself how to fulfill this task and tried something by yourself.
我的问题是...
My problem is that ...
如何...?
的这样的问题将受到欢迎堆栈溢出。的
推荐答案
使用ImageMagick的和运行
Use ImageMagick and run
identify -format "%f,%w,%h\n" *.jpg > filelist.csv
示例输出
identify -format "%f,%w,%h\n" *.jpg *.png a.jpg,870,946 b.jpg,298,219 bd.jpg,3138,1877 bean1.jpg,1252,1252 bean2.jpg,500,355 bh.jpg,1877,3138 book.jpg,1715,3049 cap.jpg,300,221 fg.jpg,180,252 fractal.jpg,38400,21600 result.jpg,100,100 score.jpg,870,946 1.png,400,300 1b.png,202,102 2.png,400,300 2b.png,202,102 3.png,103,115 3b.png,202,102
或
identify -format "%f, width=%w, height=%h\n" *.jpg
如果您想为
PNG做同样的
或TIF
文件,只是改变了JPG
到png格式
或TIF
。If you want to do the same for
PNG
orTIF
files, just change thejpg
topng
ortif
.这篇关于一个文件夹中获取名称和所有影像尺寸的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!