0
Adding a jpeg to a postscript file
New Here
,
/t5/postscript-discussions/adding-a-jpeg-to-a-postscript-file/td-p/1606569
Jan 01, 2009
Jan 01, 2009
Copy link to clipboard
Copied
I have an application that needs to be able to convert a jpeg into hex ascii, and then put that hex ascii into a postscript file. I know of one way to put this jpeg into postscript, but that's without using the jpeg's hex - instead, it uses a local path to a filename. I need to know two things:
1. Within a jpeg, how can I extract the hex ascii to use in postscript, in a way that postscript will understand it? Do I need all the header information? If anyone has done this before, please shed some insight. I have found the red book to be not as helpful for this specific problem as I would like.
2. Within said postscript file, how do I enter the hex of the jpeg back so that it will display properly?
Thank you very much.
1. Within a jpeg, how can I extract the hex ascii to use in postscript, in a way that postscript will understand it? Do I need all the header information? If anyone has done this before, please shed some insight. I have found the red book to be not as helpful for this specific problem as I would like.
2. Within said postscript file, how do I enter the hex of the jpeg back so that it will display properly?
Thank you very much.
TOPICS
Programming
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
New Here
,
/t5/postscript-discussions/adding-a-jpeg-to-a-postscript-file/m-p/1606570#M94
Jan 02, 2009
Jan 02, 2009
Copy link to clipboard
Copied
Eric,
One way to to use jpg images in PS files is to convert the jpg file to eps by one of many applications, e.g. by Acrobat or GraphicConverter.
Then you use PS's image operator, the one that takes a dictionary as an argument.
If you use GC to do the conversion, all image data is in front of you, in the eps header,
in a few lines.
You need to consider a few things:
a) When you do the jpg -> eps conversion, you may end-up with a huge file.
You need to read the application's manual to find out how to make it smaller, if this
is acceptable regarding quality.
b) To put the image where you want it on the paper, you have several options for scaling
and translation. You may ask the operator not to do any of these by setting the
`imagematrix' to 'matrix' and do your translate-scale operations before you call `image',
or you may ask `imagematrix' to do everything.
Just be careful, 'cause your already existing PS code is likely to have used translate and
scale, and these operations are cumulative.
c) If the eps file is small, you may copy it in your PS after the `image' operator
(as `currentfile').
If it is too big, leave it outside and use the `run' command to read it in at runtime.
d) If you need to do such things many times, it pays to look around for a a asciihex to
ascii85 converter that makes your eps file 5/8 in size without loss of quality.
Be prepared for a bit of (lot of) frustration (NOT your fault) and good luck.
Miklos
One way to to use jpg images in PS files is to convert the jpg file to eps by one of many applications, e.g. by Acrobat or GraphicConverter.
Then you use PS's image operator, the one that takes a dictionary as an argument.
If you use GC to do the conversion, all image data is in front of you, in the eps header,
in a few lines.
You need to consider a few things:
a) When you do the jpg -> eps conversion, you may end-up with a huge file.
You need to read the application's manual to find out how to make it smaller, if this
is acceptable regarding quality.
b) To put the image where you want it on the paper, you have several options for scaling
and translation. You may ask the operator not to do any of these by setting the
`imagematrix' to 'matrix' and do your translate-scale operations before you call `image',
or you may ask `imagematrix' to do everything.
Just be careful, 'cause your already existing PS code is likely to have used translate and
scale, and these operations are cumulative.
c) If the eps file is small, you may copy it in your PS after the `image' operator
(as `currentfile').
If it is too big, leave it outside and use the `run' command to read it in at runtime.
d) If you need to do such things many times, it pays to look around for a a asciihex to
ascii85 converter that makes your eps file 5/8 in size without loss of quality.
Be prepared for a bit of (lot of) frustration (NOT your fault) and good luck.
Miklos
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
_Eric_Burton_
AUTHOR
New Here
,
/t5/postscript-discussions/adding-a-jpeg-to-a-postscript-file/m-p/1606571#M95
Jan 02, 2009
Jan 02, 2009
Copy link to clipboard
Copied
Miklos, thank you for your help. I tried the method you suggested, with acrobat 9. I converted a practice jpg into eps by export, but I got a large file that I view in windows notepad. Several pages of eps code, and toward the end of the file, a huge block of jibberish which I believe is the binary of the actual image data. Here is a sample:<br /><br />%j=S,4[V\(4Zktq6:O4'7f>^O69@J!6:+%,5<_7r5!2)#7n#p;6U3q$76`js6:4%$6U4"*6V'I&83oC&<br />6;9X26:*h&770O.6UO.*6:1Z=$9q$J5s[Us6:*t(rBpTOs$?TNs$H`Qs$H`OrBgWQ6:1`?nNn'V4[M&4<br />!"fMD#R^qJ$P<gW%L<7K$47.Kq[?40%L`aQ$4I:N%h8sT$jQtE%gNCJ$4I.M&I/RS%13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Y>2!WN/s!<iQ-!!!*b>9"pkP9!WE'*"9JQ,"U5,5!<E*#rWjDN<br />!s8Z3!WiQ3$O?n;"9JQ(!!!$#!!!*'!<N-&%0Qe8!<E0$!<WE)!<N>q!WN5u!W<-!!WN8t!<r]4!sBG@<br />!qu\H!;?I(4L5"f!sJi1#6b89!s/N+r;lcsqZ-j'"pP/2!<*!!"TAK%!%.jK!<<6(!<N?*!W`N?3>;St<br />"pG#0!rrB(!!3<+!s/K(!WiB'!Wr6!!X8o5q?$[!rrW-"quR!&!s8Q)qZ?cur<!!"q#V96!s8_3$Zc@N<br />"9\c+!W`<'!W`<'!;llr!;cd"!!33&!r`0I!sJc/!WW<*!s&H'!rr?'!!!$"!sTMB"9JZ,!WrK(!!*'$<br /><br />This block is about 10 times the size in the file, so I am at a loss. Unless I am looking in the wrong place.<br /><br />It also may help if I am more clear about my desires. For the final implementation of my application, I need to be able to find a jpg on a user's computer, turn it into hex ascii so that a different system can process it (and while processing it, keep it in it's native form), and then paste that hex back into a final report to be printed (the postscript file).<br /><br />I hope this makes sense.
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
_Eric_Burton_
AUTHOR
New Here
,
/t5/postscript-discussions/adding-a-jpeg-to-a-postscript-file/m-p/1606572#M96
Jan 02, 2009
Jan 02, 2009
Copy link to clipboard
Copied
...continued
This block is about 10 times the size in the file, so I am at a loss. Unless I am looking in the wrong place.
It also may help if I am more clear about my desires. For the final implementation of my application, I need to be able to find a jpg on a user's computer, turn it into hex ascii so that a different system can process it (and while processing it, keep it in it's native form), and then paste that hex back into a final report to be printed (the postscript file).
I hope this makes sense.
This block is about 10 times the size in the file, so I am at a loss. Unless I am looking in the wrong place.
It also may help if I am more clear about my desires. For the final implementation of my application, I need to be able to find a jpg on a user's computer, turn it into hex ascii so that a different system can process it (and while processing it, keep it in it's native form), and then paste that hex back into a final report to be printed (the postscript file).
I hope this makes sense.
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
_Eric_Burton_
AUTHOR
New Here
,
/t5/postscript-discussions/adding-a-jpeg-to-a-postscript-file/m-p/1606573#M97
Jan 02, 2009
Jan 02, 2009
Copy link to clipboard
Copied
after a bit more digging, and your help, I believe I may have found the correct path, as you had mentioned. Converting the jpeg into eps is easy, but I want to plug that eps image into a larger postscript file, that is a formatted report. I have read the Adobe EPS spec, but I want to know precisely what to do in order to add the eps to the ps. If we can already make a formatted ps file for printing, how do we add the eps file to it, so it will show up where we want it?
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
New Here
,
/t5/postscript-discussions/adding-a-jpeg-to-a-postscript-file/m-p/1606574#M98
Jan 02, 2009
Jan 02, 2009
Copy link to clipboard
Copied
Eric,<br /><br />There are a few separate issues here. <br /><br />-----------<br /><br />Getting the eps file into your PS depends on your operating system.<br />I use a Mac that is Unix based, so I get my PS into the `vi' editor, go to the place where<br />I want the eps, then issue a `:r <filename>' instruction to read it in.<br />If I want the eps at the end of the PS, I can use the `cat' command to concatenate PS and eps and place the result in a third file.<br />There must be some equivalents in case you use a PC.<br /><br />If you don't want to copy the (presumably big) image into your PS, just write in the PS at the appropriate place: <br /><br />`(filename) run'<br /><br />This leaves the eps file where it is for future viewing, and prints where you want it<br />printed without duplicating the eps.<br /><br />------------<br /><br />Where to place the image? You are on a good path with reading the eps manual and <br />probably someone else can help you here.<br />I usually do more than printing an eps as it is (e.g. clippingi, drawing borders or not, <br />adjust images to have the same width or height in print, etc), so I only use eps to give <br />me the image's essentials, then use the PS operator `image'.<br /><br />If you use Acrobat for conversion, it produces a huge file header from which I've never had the patience to extract the essentials.<br />I rather use GraphicConverter for the conversion that gives me a file like this:<br /><br />%!PS-Adobe-3.0 EPSF-3.0<br />%%Creator: GraphicConverter V6.1.2 X PowerPC (CFM)<br />%%Title: DSC00151-gc.eps<br />%%CreationDate: 2009-01-03<br />%%Pages: 1<br />%%BoundingBox: 0 0 3264 2448<br />%%DocumentData: Clean7Bit<br />%%EndComments<br />%%BeginProlog<br />%%EndProlog<br />%%Page: 1 1<br />%ImageData: 3264 2448 8 3 0 9792 2 } exec<br />/languagelevel where {pop languagelevel 2 lt} {true} ifelse {<br /> (JPEG picture requires Postscript level 2<br />) dup print flush<br /> /Helvetica findfont 20 scalefont setfont 100 100 moveto show showpage stop<br />} if<br />save<br />/RawData currentfile /ASCIIHexDecode filter def<br />/Data RawData << >> /DCTDecode filter def<br />3264.00 2448.00 scale<br />/DeviceRGB setcolorspace<br />{ << /ImageType 1<br /> /Width 3264<br /> /Height 2448<br /> /ImageMatrix [ 3264 0 0 -2448 0 2448 ]<br /> /DataSource Data<br /> /BitsPerComponent 8<br /> /Decode [0 1 0 1 0 1]<br /> >> image<br /> Data closefile<br /> RawData flushfile<br /> showpage<br /> restore<br />} exec<br />FFD8FFE000104A46494600010101004800480000FFFE000C4170706C654D61<br />726B0AFFDB0084000302020202020302020203030303040604040404040705<br /> :<br /> :<br />C103BDBDCC81E7C6006E411F5F5AE9A54DB4D221AD7DDDCFFFD9><br />%%EOF<br /><br />This header is reasonably small and clear, it tells you that the image is colour images, its width and height are ... and ..., that it has two filters.<br />That's enough to construct my own dictionary for the image operator, using my own scaling and translation.<br /><br />Better still, you may write a routine that takes GC's output as it is, reads the header<br />until it finds its end, extracts Width and Height, etc, and construct the new dictionary.<br />Then it uses GC's image data to paint the picture where you want it printed.<br />This way you have your eps file intact, and you have your picture as well.<br /><br />This routine needs to be written once, then your PS file needs to contain only 2 lines<br />of extra code:<br /><br />x1 y1 x2 y2 ... maybe some other parameters ... your-routine's-name<br />(epsfile'sname) run<br /><br />Here x1 y1 x2 y2 are the coordinates of the image's viewport on paper, possibly in millimetres.<br /><br />All this needs a bit of learning and experimenting. If your problem is once-only, then<br />it is not worth the effort, and the best thing is to use the eps file as eps files were <br />originally intended to be used. That would need to read a page or two.<br />If you need to do more than placing an image into a viewport and you need to do this many times, then it pays to invest in your own image handling routine.<br /><br />Miklos
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
_Eric_Burton_
AUTHOR
New Here
,
/t5/postscript-discussions/adding-a-jpeg-to-a-postscript-file/m-p/1606575#M99
Jan 05, 2009
Jan 05, 2009
Copy link to clipboard
Copied
Miklos, thank you again for your help. I see in your GC example, the EPS code has the image information already in hex. I, and our customers, are not using Macs, so GC is not an option for us. We have been trying to get Acrobat to work, since it is a common standard. When I create an EPS file out of a jpeg using only Acrobat, I get a huge file like you noted. Tons of header, and very little help.
I am quite sure that for our purposes, we need to extract the necessary EPS data and actually put it into the larger PS file, so that at the end of the line, we have everything (report, plus the image to be imported) in one PS file.
So at first, to get used to how it works, before I build a routine to automate the process, I want to know how to manually extract the EPS data (the image) and where to paste it in the PS file.
I am quite sure that for our purposes, we need to extract the necessary EPS data and actually put it into the larger PS file, so that at the end of the line, we have everything (report, plus the image to be imported) in one PS file.
So at first, to get used to how it works, before I build a routine to automate the process, I want to know how to manually extract the EPS data (the image) and where to paste it in the PS file.
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
New Here
,
/t5/postscript-discussions/adding-a-jpeg-to-a-postscript-file/m-p/1606576#M100
Jan 07, 2009
Jan 07, 2009
Copy link to clipboard
Copied
How can I make a CD with photos I have scanned, fixed in Photoshop, then burned without them opening up Photoshop whenever viewed? Is there a special way to save them so they can stand alone when viewed? I am making the CD for a client as a reference file and just want the photos to open on the desktop with Preview or other simpler program.
Thanks for any help on this.
Donna
Thanks for any help on this.
Donna
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
_Eric_Burton_
AUTHOR
New Here
,
/t5/postscript-discussions/adding-a-jpeg-to-a-postscript-file/m-p/1606577#M101
Jan 08, 2009
Jan 08, 2009
Copy link to clipboard
Copied
Donna -
I am assuming that you are saving these image files within Photoshop as the default .psd (Photoshop Document) file format. This is not a ready to view image file, but the Photoshop "project" you are working on, with all the layers, masks, and effects you have loaded easily accessible. When you want to save a "final" version of the file for people to look at, I would recommend using the "Save As" option, and selecting a different file type. I would imagine that .jpg or .jpeg would be the best match for your needs. These files will likely pull up the default image viewer on your computer when they are opened. Of course, the default image viewer on your computer may still be Photoshop, but that is whole other issue that will likely not affect you at all.
To summarize, saving your files in a final image format like jpeg, gif, or png will make it perfect for storing on a CD and giving to clients.
I am assuming that you are saving these image files within Photoshop as the default .psd (Photoshop Document) file format. This is not a ready to view image file, but the Photoshop "project" you are working on, with all the layers, masks, and effects you have loaded easily accessible. When you want to save a "final" version of the file for people to look at, I would recommend using the "Save As" option, and selecting a different file type. I would imagine that .jpg or .jpeg would be the best match for your needs. These files will likely pull up the default image viewer on your computer when they are opened. Of course, the default image viewer on your computer may still be Photoshop, but that is whole other issue that will likely not affect you at all.
To summarize, saving your files in a final image format like jpeg, gif, or png will make it perfect for storing on a CD and giving to clients.
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
New Here
,
/t5/postscript-discussions/adding-a-jpeg-to-a-postscript-file/m-p/1606578#M102
Jan 09, 2009
Jan 09, 2009
Copy link to clipboard
Copied
Eric:
I appreciate your advice and must admit that I learn about Photoshop on an ad hoc basis so am never sure that I am doing things very efficiently. I saved the photos first as jpegs from the scanner, then as Tiffs or Jpegs to be used in Quark, then converted the finished pages to eps, then ai files which I bring to the print shop. It seems to provide the best color.
The whole CD idea seemed simple on its face, but then I worried that the client who didn't have Photoshop would not be able to view the photos.
Your advice is very useful and I appreciate your time.
Donna
I appreciate your advice and must admit that I learn about Photoshop on an ad hoc basis so am never sure that I am doing things very efficiently. I saved the photos first as jpegs from the scanner, then as Tiffs or Jpegs to be used in Quark, then converted the finished pages to eps, then ai files which I bring to the print shop. It seems to provide the best color.
The whole CD idea seemed simple on its face, but then I worried that the client who didn't have Photoshop would not be able to view the photos.
Your advice is very useful and I appreciate your time.
Donna
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
Advocate
,
LATEST
/t5/postscript-discussions/adding-a-jpeg-to-a-postscript-file/m-p/1606579#M103
May 02, 2010
May 02, 2010
Copy link to clipboard
Copied
Eric,
Your problem is surely solved, but just for the record the tool to fulfill exactly your requirement is available here:
http://www.pdflib.com/download/free-software/jpeg2ps/
[I did not see it mentioned in the answers.]
- Michael
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more

