Building and compositing image in one step
Posted: 2018-09-04T15:32:45-07:00
I have written code that works for a custom labeling application where labels are built and then printed on the fly. It all works properly, but execution speed is a problem. The code takes about ~3 second to run, and I need it to run much faster, maybe ~ < 1s. I am currently making the label overlays I need to place onto a template image as individual PNG files, and then compositing them together into the final file.
magick convert -background white \
-fill black -pointsize 70 -font Arial label:"$Week" \
-rotate "-90" \
time.png
magick convert -background white \
-fill black -pointsize 500 -font Free-3-of-9-Regular label:"$Barcode" \
-rotate "-90" \
barcode.png
magick convert barcode.png -resize 100x600\! barcode.png
magick convert -background white \
-fill black -pointsize 200 -font Arial-Bold label:"$Serial" \
serial.png
magick composite -geometry +320+950 serial.png template.png $output
magick composite -geometry +75+800 time.png $output $output
magick composite -geometry +75+150 barcode.png $output $output
can someone point me in the right direction on taking these steps where files are written to the drive (slowly) and compiling all this together into a single convert command such that the entire operation is done in memory?
magick convert -background white \
-fill black -pointsize 70 -font Arial label:"$Week" \
-rotate "-90" \
time.png
magick convert -background white \
-fill black -pointsize 500 -font Free-3-of-9-Regular label:"$Barcode" \
-rotate "-90" \
barcode.png
magick convert barcode.png -resize 100x600\! barcode.png
magick convert -background white \
-fill black -pointsize 200 -font Arial-Bold label:"$Serial" \
serial.png
magick composite -geometry +320+950 serial.png template.png $output
magick composite -geometry +75+800 time.png $output $output
magick composite -geometry +75+150 barcode.png $output $output
can someone point me in the right direction on taking these steps where files are written to the drive (slowly) and compiling all this together into a single convert command such that the entire operation is done in memory?