当前位置: 首页 > 工具软件 > PythonMagick > 使用案例 >

PythonMagick笔记

寇开畅
2023-12-01

下载路径

路径: https://pypi.org/project/PythonMagick/

whl下载路径:https://www.lfd.uci.edu/~gohlke/pythonlibs/#pythonmagick

帮助文档:http://www.imagemagick.org/Magick++/Documentation.html

API:http://www.imagemagick.org/script/api.php

ICC路径:https://www.adobe.com/support/downloads/iccprofiles/iccprofiles_win.html

制作  ICC的软件:https://www.chessclub.com/download-software/icc-for-windows/

使用案例:

#!/usr/bin/env python
# -*- coding: UTF-8 -*-
# Time      :  12:19
# Email     : spirit_az@foxmail.com
# File      : tst.py
__author__ = 'ChenLiang.Miao'
# import --+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ #
import PythonMagick as mgk

# function +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ #
reload(mgk)

转换色彩空间:

def getICC(fileName):
    color = mgk.Blob()
    im = mgk.Image(fileName)
    im.write(color, "icc")
    return color


def changeColorSpace():
    cmyk = getICC("CMYK.icc")
    temp = mgk.Image("zbrush-vector-logo.png")
    temp.iccColorProfile(cmyk)
    temp.write("zbrush-vector-logo_c.png")

图片转ico:

需要注意转换的尺寸不能大于现有图片尺寸

def pngToIco():
    temp = mgk.Image("zbrush-vector-logo.png")
    temp.sample('256x256')
    temp.write("zbrush-vector-logo.ico")

 

 类似资料: