I'm looking for an efficient way of computing and memory to use ImageMagick in a Python program to retrieve batch sizes of photos.
At first I used the current favorite ImageMagick-Python package, Wand. I tried and it was slow. So I started testing by simply executing ImageMagick using subprocess.check_output (). The subprocess was over 10 times faster.
My question is: what do other people experience? Is there a way to use Wand faster?
Wand took 1.2 seconds :
1.jpg: 3264x2448
2.jpg: 1600x1200
3.jpg: 1700x1101
4.jpg: 1600x1200
5.jpg: 3648x2736
6.jpg: 2789x1980
7.jpg: 2400x1600
8.jpg: 3648x2736
processed 8 files in 1.236s
The subprocess took 0.1 seconds to get the same files:
1.jpg: 3264x2448
2.jpg: 1600x1200
3.jpg: 1700x1101
4.jpg: 1600x1200
5.jpg: 3648x2736
6.jpg: 2789x1980
7.jpg: 2400x1600
8.jpg: 3648x2736
processed 8 files in 0.102s
Wand Code:
for filename in files:
with wand.image.Image(filename=filename) as img: return img.width, img.height
Subprocess Code:
subprocess.check_output(['identify', '-format', '%f:%w:%h\\n', 'path/to/imgs/*.jpg'])
, , ImageMagick Wand. , Wand, , Wand .
!