日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > python >内容正文

python

python中eps参数_2019-01-23 python PIL 编辑 EPS 文件调整大小并拼接-失败告终

發布時間:2023/12/15 python 24 豆豆
生活随笔 收集整理的這篇文章主要介紹了 python中eps参数_2019-01-23 python PIL 编辑 EPS 文件调整大小并拼接-失败告终 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

原本是想找到python 操作emf文件保存成ai或者eps或者svg文件,然后拼圖。無果。

image.png

EPS文件介紹

找到一個批量轉換emf到eps的軟件emftoeps

用這個把部分emf轉換成eps后,AI打開,很清晰

image.png

想嘗試python操作eps來拼接

參考

C:\ProgramData\Anaconda3\Lib\site-packages\ghostscript;

C:\ProgramData\Anaconda3\Lib\site-packages\ghostscript-0.6.dist-info;

還是要用PIL

http://effbot.org/imagingbook/format-eps.htm

PIL identifies EPS files containing image data, and can read files that contain embedded raster images (ImageData descriptors). ** If Ghostscript is available, other EPS files can be read as well. The EPS driver can also write EPS images.

** If Ghostscript is available, other EPS files can be read as well. The EPS driver can also write EPS images.

https://pypi.org/project/elaphe3/0.2.0/

If you want to render barcode into bitmap image, EpsImagePlugin of Python Imaging Library (http://www.pythonware.com/products/pil) or Pillow is required.

** Note that EpsImagePlugin requires Ghostscript is correctly installed**.

一定還是要裝好Ghostscript

安裝Ghostscript

下面就試著解決這個問題:

官方網站下載Ghostscript 9.26 for Windows (64 bit) 22.3M

https://www.ghostscript.com/download/gsdnld.html

image.png

安裝,再試一下,path加入路徑,一定要有bin在里面

c:\Program Files\gs\gs9.26\bin;

Image.open(emf).save(outfile,"tiff")

---

Traceback (most recent call last):

File "", line 1, in

Image.open(emf).save(outfile,"tiff") # added "JPEG"

File "C:\ProgramData\Anaconda3\lib\site-packages\PIL\Image.py", line 1899, in save

self.load()

File "C:\ProgramData\Anaconda3\lib\site-packages\PIL\EpsImagePlugin.py", line 337, in load

self.im = Ghostscript(self.tile, self.size, self.fp, scale)

File "C:\ProgramData\Anaconda3\lib\site-packages\PIL\EpsImagePlugin.py", line 137, in Ghostscript

raise WindowsError('Unable to locate Ghostscript on paths')

OSError: Unable to locate Ghostscript on paths

還是不行。。。

又看到:

to the end of the variable. It should be separated from the previous entry by a semicolon.

I had to restart for the changes to take effect.

重啟試一下吧。。

重啟之后運行不報錯了,貌似是可以用了。

不過,保存出來的圖片還是喪失掉了可編輯性,分辨率掉的厲害。

image.png

看來還是不行。。

讀取eps,調整分辨率,還保存成可編輯的eps,這么困難?

如果不改變分辨率只是縮放,試一下這個

May be it is best if you just specify the desired width instead of the resolution - for example if you want to have it 1677 pixels wide:

def open_eps(filename, width=None):

original_width = float(Image.open(filename).size[0])

im = Image.open(filename)

if width is not None:

im.load(scale=width/original_width)

return im

im = open_eps('testfile.eps', 1677)

1-24 繼續折騰一下,找了Pillow官網的eps說明如下

PIL identifies EPS files containing image data, and can read files that contain embedded raster images (ImageData descriptors). If Ghostscript is available, other EPS files can be read as well. The EPS driver can also write EPS images. The EPS driver can read EPS images in L, LAB, RGBand CMYK mode, but Ghostscript may convert the images to RGB mode rather than leaving them in the original color space. The EPS driver can write images in L, RGB and CMYK modes.

If Ghostscript is available, you can call the load() method with the following parameter to affect how Ghostscript renders the EPS

Affects the scale of the resultant rasterized image. If the EPS suggests that the image be rendered at 100px x 100px, setting this parameter to 2 will make the Ghostscript render a 200px x 200px image instead. The relative position of the bounding box is maintained:

im = Image.open(...)

im.size #(100,100)

im.load(scale=2)

im.size #(200,200)

EPS Module 說明

放棄了。。。

總結

以上是生活随笔為你收集整理的python中eps参数_2019-01-23 python PIL 编辑 EPS 文件调整大小并拼接-失败告终的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。