简体   繁体   English

使用Python解析Adobe Illustrator(.ai)文件

[英]Parse Adobe Illustrator (.ai) files with Python

I'm using Python under Linux. 我在Linux下使用Python。 Could you please recommend some libs or command line tools to parse Adobe Illustrator (.ai) files which I can use in my Python program? 你能推荐一些libs或命令行工具来解析我可以在我的Python程序中使用的Adobe Illustrator(.ai)文件吗?

What I need to do includes: 我需要做的包括:

  1. Convert .ai files to .jpeg or .png images 将.ai文件转换为.jpeg或.png图像
  2. Extract text from .ai files 从.ai文件中提取文本
  3. Read .ai files information (eg version number, something like psdparse for AI) 读取.ai文件信息(例如版本号,类似于psdparse for AI)

I need it under Ubuntu so I cannot use win32com 我在Ubuntu下需要它,所以我不能使用win32com

Perhaps you should consider using Illustrator to save files as svg. 也许你应该考虑使用Illustrator将文件保存为svg。 It seems to be easier to parse SVG than the illustrator format. 解析SVG似乎比插图画家格式更容易。 Examples of manipulation of svg using python (specifically conversion to .png) can be found in other questions, such as the one below. 使用python(特别是转换为.png)操作svg的示例可以在其他问题中找到,例如下面的问题。

Convert SVG to PNG in Python 在Python中将SVG转换为PNG

I think many modern .AI files are just extended PDF files. 我认为许多现代.AI文件只是扩展的PDF文件。 A quick test would be: rename the .AI to .PDF and see if your PDF reader can open it. 快速测试是:将.AI重命名为.PDF并查看您的PDF阅读器是否可以打开它。 If so, there are plenty of tools to deal with PDF files . 如果是这样,有很多工具可以处理PDF文件

If you have older .AI files then you can try Uniconvertor . 如果您有较旧的.AI文件,那么您可以尝试使用Uniconvertor It is Python, perhaps you can import some functionality from it. 它是Python,也许你可以从中导入一些功能。

[update] [更新]

This answer is quite old. 这个答案很老了。 If it does not work for you leave a comment with what went wrong. 如果它不起作用,请对出错的地方发表评论。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM