0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

備忘録:pythonでpngファイルが開けないという問い合わせについての対処法など

Posted at

背景

自分の作ったpythonプログラムを使ってもらっていて画像が開けないと苦情があった。確かに開けず、初めは原因がわからなかったが、のちにそのファイルの中身が実は.pngではなかったことがわかった。

対処法

ファイル形式の確認

ターミナルに以下のコマンドを投げ込んで、確認したらよかった。

プロンプト
file image.png
実際の出力結果
image.png: ISO Media, HEIF Image HEVC Main or Main Still Picture Profile

拡張子が.pngだったしても、中身がHEIF形式みたいで、今までこういった画像ファイルが存在することを知らず、初めて知った。(HEIFはApple製品で使われている規格みたい)

じゃぁどうやって対処するのか?

画像を"プレビュー"で開き、「ファイル>書き出す」で再度変換すれば、ptyhonプログラムから開けるようになった。

書き出した後
image.png: PNG image data, 3024 x 4032, 8-bit/color RGB, non-interlaced

補足事項

この記事はMacOSの環境を前提としたものです。

0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?