Need a script to check if pictures are intersecting

Would it be possible for someone to make a script to check if one or more pictures are intersecting?

The reason that I need this script is because I have a few puzzles planned in my main game project that will incorporate pictures. For example, I have one in the works that has you controlling a picture while you dodge other pictures coming down from above. It is possible to event, but very tedious setting the timing up on it, which is what lead me to post this topic.

A big thanks to anyone who may step forward to take this script on~
Guessing you're Cassius from the rmn Discord, either that or you have freakishly good timing of asking the same obscure questions as someone who isn't you. 😛

Are you checking for the boundaries of the pictures intersecting (the rectangle they inhabit) or the actual pixels that aren't transparent?

Edit: I posted this on Discord as well, but for anyone else who might need a script for this:

Ruby:
class Spriteset_Map
  attr_accessor :picture_sprites
end

class Scene_Map
  attr_accessor :spriteset
end

class Game_Map
  def pics_intersect?(id1, id2)
    sprites = SceneManager.scene.spriteset.picture_sprites
    sprite1 = sprites[id1]
    sprite2 = sprites[id2]
    if sprite1 && sprite2
      u1 = sprite1.y
      d1 = u1 + sprite1.height
      l1 = sprite1.x
      r1 = l1 + sprite1.width
      u2 = sprite2.y
      d2 = u2 + sprite2.height
      l2 = sprite2.x
      r2 = l2 + sprite2.width
     
      ((r1 > l2 && l1 < r2) && (d1 > u2 && u1 < d2))
    end
  end
end

This checks intersection of the picture boundaries, haven't gotten it working for pixel collision yet.

Original thread: https://forums.rpgmakerweb.com/threads/need-a-script-to-check-if-pictures-are-intersecting.144715/