Code: Select all
Version: ImageMagick 6.8.9-1 Q16 x86_64 2014-07-11 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2014 ImageMagick Studio LLC
Features: DPC Modules
Delegates: bzlib djvu fftw fontconfig freetype gslib jng jpeg lcms ltdl lzma png ps tiff webp x xml zlib
On OS X 10.10 Yosemite DP3. That said, I'd tried to configure from MacPorts with Q8 before so that might've messed something up. I decided to port uninstall and port install again with no extra options defined. In any case, after I did that, I started playing around with manual tests and for whatever reason my MIFFs started coming out correct. I'm not sure what changed, but I'll take it.
That said, I've modified my code a bit, because I did a quick test with multi-page MIFFs (rather than a ton of individual files, because HFS+ filesystem performance with generating tons and tons of little files is notoriously bad, plus fseventsd really doesn't like it) and it was FAST AS HECK. It seems the MIFF format is very kind to accessing specific pages. I mean, it was with only 46 frames, but it seemed so much faster than before that I'm currently doing a test on a full-size barcode (1920 frames).
Code: Select all
FILES=($(find "${1}" -type f | egrep -i "\.jpg$" | sort))
i=1
echo -e "Dumping MIFFs..."
for f in ${FILES[*]}; do
framedir="f_$(printf %04d $i)"
mkdir -p tempcrops
convert ${f} +gravity -crop 1080x1 +repage tempcrops/${framedir}.miff
(( i++ ))
done
FILES=($(find "tempcrops/" -type f | sort))
echo -e "Assembling barcodes..."
for (( c=0; c<1920; c++ )); do
echo "$(printf %04d $((${c}+1))) of 1920"
columns=()
for f in ${FILES[@]}; do
columns+=("${f}[${c}]")
done
montage ${columns[@]} -mode Concatenate -tile 1x miff:- | convert - -rotate -90 barcode_$(printf %06d ${c}).png
done
rm -rf tempcrops
We'll see if this maintains speed at "full scale" (doing full-width barcodes and the full number of them).
EDIT: Yep, this is significantly faster—about 12 seconds per barcode, rather than the minute and a half it was taking before, and with a lot less I/O activity (which verifies that reading specific pages from multi-page MIFFs doesn't require reading the entire file). That's still 6.5 hours to do a full 1920 barcodes, but that's a heck of a lot better than 2.5 days. I might look into using netpbm and that Perl script to output the proper sort of MIFF straight from ffmpeg for animation mode, or otherwise optimizing bits where there's some waste, currently. But I think this is enough of an improvement that I'm done for now.
Thanks to both of you for helping out! I really appreciate it.