Look at the javasource of Image-Resize module in the app-store Maybe you can re-use this code for your specific purposes.
Thumbs up if you read this in 2024 😄
Nowadays, the CommunityCommons Marketplace module offers a Java Action named GetImageDimensions. The CommunityCommons module is platform supported by Mendix.