Skip to content

How to overlay and repeat non-animated image over an animated one? #353

Answered by jcupitt
slnc asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @slnc,

That'll work, but it'll be pretty slow since every pixel will need to pass through a stack of n_pages composite operations. A quicker solution would be to copy the character n_pages times vertically, then do a single composite for the whole animation.

replicate tiles images:

https://www.rubydoc.info/gems/ruby-vips/Vips/Image#replicate-instance_method

It's extremely quick (it just copies pointers), so you can use it instead of any kind of loop over the X and Y dimensions.

Something like:

require 'vips'

character = Vips::Image.new_from_file(ARGV[0])
aura = Vips::Image.new_from_file(ARGV[1], access: 'sequential')

character = character
    .replicate(1, aura.get("n-pages"))
aura
    

Replies: 3 comments 4 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@slnc
Comment options

Answer selected by slnc
Comment options

You must be logged in to vote
3 replies
@slnc
Comment options

@jcupitt
Comment options

@slnc
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants