chillerlan / php-qrcode

A PHP QR Code generator and reader with a user-friendly API.
https://smiley.codes/qrcode/
Apache License 2.0
2.02k stars 302 forks source link

Just the raw base64? #184

Closed strider72 closed 1 year ago

strider72 commented 1 year ago

Hi! I'm trying to get this to work with a 2FA library. The format for the library is to get two separate values: 1) mimetype (e.g. image/svg+xml), and 2) the image itself in base64.

Your plugin pre-combines these values in the string when it renders as dataurl.

Is there any way to easily get the base64 image string? Am I best off just exploding the string at the comma and grabbing the second element?

codemasher commented 1 year ago

Hey! The base64 data URI is a convenience functionality so that the output can be used directly in an <img src="" /> tag without further processing (e.g. cache a .png file). So yes, the simplest way is to just explode the data URI of the comma ,. Alternatively, you could set QROptions::$imageBase64 to false and then base64_encode() the content by yourself, but i guess that's more overhead.