openssl already provides two ways of reading public keys in PEM format:
openssl ec -pubin -text -noout -in key.pemopenssl asn1parse < key.pem
Unfortunately, both provide text output which is hard to parse and use in an automated manner. This script provides a third way, and the output is structured JSON, using pure bash. See examples below.