• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Extract image from PostScript file

New Here ,
Jan 28, 2019 Jan 28, 2019

Copy link to clipboard

Copied

Hello Everyone.
I'm trying to extract an image from a PostScript file but with no success. In order to get the image, i actually convert the .ps file to .pdf - but it just shows blank.

I believe i did everything correctly according to the PostScript reference manual. So i would like to ask for any help.

My PostScript file is:

%!PS-Adobe-3.0 EPSF-3.0

%%Creator:  PostScript Test

%%BoundingBox: 0 0 1465 1191

%%LanguageLevel: 2

%%Pages: 1

%%DocumentData: Clean7Bit

100 100 scale

1465 1191 8 1465 0 0 -1191 0 1191]

/ASCIIHexDecode filter

/RunLengthDecode filter

{currentfile 3 100 mul string readhexstring pop} bind

false 3 colorimage

...hex image data...

>

Any input is very appreciated

Thanks a lot

Link for the full file on Google Drive:

TestPostScript.ps - Google Drive

TOPICS
Programming

Views

728

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Jan 28, 2019 Jan 28, 2019

Copy link to clipboard

Copied

Typically an image dictionary would be used verses the colorimage operator e.g.

%!PS

10 10 scale

36 36 translate

/temp 4 string def

/DeviceCMYK setcolorspace

<<

  /ImageType 1

  /Width 8

  /Height 12

  /BitsPerComponent 1

  /Decode [ 0 1 0 1 0 1 0 1 ]

  /ImageMatrix [1 0 0 1 0 0]

  /DataSource { currentfile temp readhexstring pop }

%  /DataSource currentfile /ASCII85Decode filter

>>

image

AA77A7C7F770AAC7EDEDEDED

AA77A7C7F770AAC7EDEDEDED

AA77A7C7F770AAC7EDEDEDED

AA77A7C7F770AAC7EDEDEDED

showpage

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Feb 07, 2019 Feb 07, 2019

Copy link to clipboard

Copied

LATEST

Hi.

abeddie’s comment is apt: using image with a dictionary is a much better approach than the colorimage operator.

In addition, note that rgb images often have a fourth byte added to each rgb sample, making the pattern “rgba rgba rgba…”, which is a problem because PostScript expects only three components per sample: rgb rgb rgb…

For my PostScript classes, I used to take image data from Photoshop EPS files and would have to run a short program that stripped every fourth byte from the data before I could use it.

As a side note, I’m assuming that the line in your sample code

  1465 1191 8 1465 0 0 -1191 0 1191]

was just a typo, omitting the opening bracket for the image matrix.

Best regards,

John

-------

John Deubert

Acumen Training

PostScript & PDF consulting and training

john@acumentraining.com

www.acumentraining.com

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines