LoginSignup
1
0

More than 1 year has passed since last update.

base64をimg/pngに保存した時にちょっとつまづいたこと。文頭の`data:image/png;base64`は消す。

Posted at

以下の質問いただきました。
「パソコンのwebカメラで写真撮って、jpgとかpngで保存したいです」

と言うことで、

  1. まずは「ブラウザで写真を撮影する方法」を確認したところ、すでに記事があるのでこちらを参考

  2. また、PHPにはbase64_decode関数がある様子。
    (公式はこちら/base64_decode)

と言うことで,base64形式を取得してデコードすりゃいいんじゃないかと思ったんですが、どうもうまくいかない。

で、確認するとエンコードされたbase64の文頭のdata:image/png;base64はdecode時には不要なんですね。
参考

ということで、サンプル。
https://github.com/fukushimasurao/base64_to_img_sample

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0