LoginSignup
4
2

More than 1 year has passed since last update.

【Python】png,jpeg,gif画像をeps形式に変換する

Posted at

PillowライブラリのImageモジュールにより,png,jpeg,gifなどの画像をeps形式に変換することができます.
Pillowをインストールしているのであれば,怪しいフリーソフトをダウンロードする必要はありません.

img2eps.py
import os
from PIL import Image

image_path = 'C:/Users/' + os.getlogin() + '/Downloads/'
image_file = ['ABC.png', 'DEF.jpg', 'GHI.gif']

for i in range(len(image_file)):
    im = Image.open(image_path + image_file[i])
    # print(im.mode)
    fig = im.convert('RGB')
    fig.save(image_path + image_file[i].split('.', 1)[0] + '.eps', lossless = True)

ダウンロードフォルダ内にある 'ABC.png', 'DEF.jpg', 'GHI.gif' という3つの画像をすべてeps形式に変換して保存します.
Imageモジュールが読めるのであれば,その他の拡張子でも応用可能です.適宜改変してご利用ください.

個人的にTeX文書を書く機会があったので,作成しました.


【参考】

4
2
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
4
2