A bash
method, using special array features; probably translatable to zsh
with some modification:
image_files=(*.svg) # use your own glob expression
n=200 # number of files per command line; adjust to taste
for ((i=0; i < ${#image_files[@]}; i+=n)); do
montage -size 256x256 "${image_files[@]:i:n}" output-"$i".png
done
As you note, you don't need the whole ImageMagick package. You just need identify
.
You will also need the libraries the executable links to (and the libraries those libraries link to).
> whereis identify
identify: /bin/identify /usr/bin/identify /usr/share/man/man1/identify.1.gz
> ldd /bin/identify
ldd
will show a list. When I did this, it included some X libs, libjpeg, etc. and two libraries clearly from the ImageMagick package, libMagickCore
and libMagickWand
. Those look to be linked to the same bunch of things, so if you have that, identify
should work.
You don't have to download an entire image in order to get the dimensions, because these are in a header at the beginning of the file and that's what identify
looks at. For example, here I'm copying the first 4 kB from a complete jpeg into a new file:
dd if=real.jpg of=test.jpg bs=1024 count=4
4 kB should be more than enough to include the header -- I'm sure you could do it with 1/4 that amount. Now:
>identify test.jpg
test.jpg JPEG 893x558 893x558+0+0 8-bit DirectClass 4.1KB 0.000u 0:00.000
Those are the correct dimensions for real.jpg
. Notice, however, that the size (4.1KB) is the size of the truncated file, since that information is not from the image header.
So: you only have to download the first kilobyte or so of each image.
Best Answer
Sounds like a job for the
montage
command.