Imagemagcik遮罩

时间:2020-10-02 07:34:49

标签: python-3.x pdf imagemagick

我从PDF中提取了原始数据,并尝试使用Imagemagick将其转换为BMP。

语言是Python3。 但是带有 Smask 的DeviceRGB无法正确转换,并且看起来不像原始图像。

  • 原始图片
...
ColorSpace/DeviceRGB/
BitsPerComponent 8/
Interpolate false/
SMask 31 0 R/
Filter/FlateDecode/
Length 24011>>
stream...
  • XObject
...
31 0 obj
<</Type/XObject/
Subtype/Image/
Width 414/
Height 165/
ColorSpace/DeviceGray/
Matte[ 0 0 0] /
BitsPerComponent 8/
Interpolate false/
Filter/FlateDecode/
Length 11979>>
stream
...

这是imagemagick命令,用于转换原始数据。

sub_proc_cmd = [
    'convert',
    '-size', str(json_data['Width']) + 'x' + str(json_data['Height']),
    '-depth', str(json_data['BitsPerComponent']),
    '-colorspace', 'RGB',
    raw_image,
    'BMP3:' + raw_image + '.bmp']
proc_status = subprocess.check_call(sub_proc_cmd)

原始图片: Here

已转换的图像: Here

0 个答案:

没有答案