How to obtain the geometry of an image attachment

Added by Five Above Infinity 17 days ago

Is there a way to obtain the geometry parameters, that is height and width, of an attachment, in case this attachment is an image file?

For example something like this:

attachment.latest_attach(obj.attachments, "test.png");
width = attachment.something...
height = attachment.something...

I have looked into attachment.rb (
but have not yet discovered the right track to keep going.

Maybe someone has a hint for me.

The background is, I am working on a Plugin/Macro which displays the attached image with some added extra annotations and I need to determine the aspect ratio of the image attachment before generating the output.