Page 1 of 1

Fast Image Overlay (constant overlay image)

Posted: 2018-05-16T12:23:59-07:00
by dkode
I want to overlay an image over a background image.

In my case the overlay image is constant (for example a logo or signature) but background image is variable.
Is there any way to leverage the fact that overlay image is constant?
I tried using .mpc file but gains are negligible.
My primary concern in performance as i have to do this in runtime/online .

There is other option where i can use draw command in place of overlay. But i have not found a consistent way to figure out font dimensions when rendered wrt to pointsize. I tried the methods described in imagemagick doc for font metric calculation. But those are 2-3 pixels inconsistent when rendered.
If anybody has better font metrics calculation method, please share.
Also Does draw method first creates image and overlay on background, or does it change the background pixels in place without creating any temporary image?

Re: Fast Image Overlay (constant overlay image)

Posted: 2018-05-16T12:58:54-07:00
by snibgo
If your overlay is small compared to the input background and output, then reducing the time needed to read the overlay to zero would not reduce the overall time by much.

If your overlay is large, and you can read many input backgrounds into memory at the same time, you can read the overlay just once and use "-layers composite", then write the outputs.

For details of how "-draw" works, see draw.c.

Re: Fast Image Overlay (constant overlay image)

Posted: 2018-05-16T13:07:20-07:00
by dkode
Thanks snibgo,

But setup is over HTTP, so i get to do all this whenever a request comes, hence cannot read multiple images at once.
In my case overlay image is small.

Also sometimes i may need to resize my overlay image when background image is not of predefined size, So any option available for that like svg draw or something like that.