Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/332.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在python中创建cmyk映像_Python_Image_Cmyk - Fatal编程技术网

如何在python中创建cmyk映像

如何在python中创建cmyk映像,python,image,cmyk,Python,Image,Cmyk,是否可以像rgb图像一样使用python创建cmyk图像? 假设我们有一个二维数组,每个元素是一个4维向量!如何将其转换为cmyk图像?您可以在本文档中找到任何有用的信息 这个问题呢 你看过图书馆里的图片了吗 from PIL import Image im = Image.fromarray(A, mode="CMYK") im.save("your_file.jpeg") 我已经在我的Linux Ubuntu中创建了一个名为ImageMode.py的python脚本,虽然代码没有经过优化

是否可以像rgb图像一样使用python创建cmyk图像?
假设我们有一个二维数组,每个元素是一个4维向量!如何将其转换为cmyk图像?

您可以在本文档中找到任何有用的信息

这个问题呢

你看过图书馆里的图片了吗

from PIL import Image
im = Image.fromarray(A, mode="CMYK")
im.save("your_file.jpeg")

我已经在我的Linux Ubuntu中创建了一个名为
ImageMode.py
的python脚本,虽然代码没有经过优化,但运行良好

python3 ImageMode.py test.jpg

如果图像是RGB,那么输出将是
test\u CMYK.jpg

你做了哪些背景工作来回答这个问题?@aryamcarthy不幸的是,我是新用户,所以堆栈溢出目前不接受我的投票。谢谢,但是那些链接没有回答这个问题!1.答案是“是的”——这是可能的——文档将为您提供完成任务所需的任何信息。但是做些事情来改变你的阵列是你的工作。
from PIL import Image
import sys

arg = sys.argv
if len(arg)==2:

   [file,ext] = str(arg[1]).split('.')
   image = Image.open(arg[1])

   if image.mode == 'CMYK':
       image = image.convert('RGB')

   elif image.mode == 'RGB':
       image = image.convert('CMYK')

   image.save(file+"_"+image.mode+"."+ext)

else:
   print("Argument missing")