Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.postscript > #1159 > unrolled thread

How can I overwrite existing files with new input to running Ghostscript?.

Started byErnie Kent <ernie@erniekent.com>
First post2012-12-09 10:14 -0800
Last post2012-12-24 19:37 -0800
Articles 20 on this page of 25 — 6 participants

Back to article view | Back to comp.lang.postscript


Contents

  How can I overwrite existing files with new input to running Ghostscript?. Ernie Kent <ernie@erniekent.com> - 2012-12-09 10:14 -0800
    Re: How can I overwrite existing files with new input to running Ghostscript?. Helge Blischke <h.blischke@acm.org> - 2012-12-09 22:13 +0100
      Re: How can I overwrite existing files with new input to running Ghostscript?. Ernie Kent <ernie@erniekent.com> - 2012-12-09 13:52 -0800
        Re: How can I overwrite existing files with new input to running Ghostscript?. "luser.droog" <luser.droog@gmail.com> - 2012-12-09 18:28 -0600
          Re: How can I overwrite existing files with new input to running Ghostscript?. Ernie Kent <ernie@erniekent.com> - 2012-12-09 17:11 -0800
    Re: How can I overwrite existing files with new input to running Ghostscript?. SaGS <sags5495@gmail.com> - 2012-12-09 20:24 -0800
      Re: How can I overwrite existing files with new input to running Ghostscript?. Ernie Kent <ernie@erniekent.com> - 2012-12-10 07:00 -0800
        Re: How can I overwrite existing files with new input to running Ghostscript?. Ernie Kent <ernie@erniekent.com> - 2012-12-10 12:39 -0800
          Re: How can I overwrite existing files with new input to running Ghostscript?. Chris <cjl@spamcop.net> - 2012-12-11 10:12 +0000
            Re: How can I overwrite existing files with new input to running Ghostscript?. Ernie Kent <ernie@erniekent.com> - 2012-12-11 11:04 -0800
              Re: How can I overwrite existing files with new input to running Ghostscript?. Chris <cjl@spamcop.net> - 2012-12-12 07:41 +0000
                Re: How can I overwrite existing files with new input to running Ghostscript?. SaGS <sags5495@gmail.com> - 2012-12-12 03:52 -0800
                  Re: How can I overwrite existing files with new input to running Ghostscript?. Chris <cjl@spamcop.net> - 2012-12-12 12:52 +0000
                    Re: How can I overwrite existing files with new input to running Ghostscript?. Ernie Kent <ernie@erniekent.com> - 2012-12-12 08:45 -0800
                      Re: How can I overwrite existing files with new input to running Ghostscript?. Chris <cjl@spamcop.net> - 2012-12-13 14:07 +0000
          Re: How can I overwrite existing files with new input to running Ghostscript?. SaGS <sags5495@gmail.com> - 2012-12-11 02:44 -0800
            Re: How can I overwrite existing files with new input to running Ghostscript?. Ernie Kent <ernie@erniekent.com> - 2012-12-11 11:05 -0800
            Re: How can I overwrite existing files with new input to running Ghostscript?. Ernie Kent <ernie@erniekent.com> - 2012-12-11 12:37 -0800
            Re: How can I overwrite existing files with new input to running Ghostscript?. Ernie Kent <ernie@erniekent.com> - 2012-12-21 21:40 -0800
              Re: How can I overwrite existing files with new input to running Ghostscript?. SaGS <sags5495@gmail.com> - 2012-12-22 00:53 -0800
                Re: How can I overwrite existing files with new input to running Ghostscript?. Ernie Kent <ernie@erniekent.com> - 2012-12-22 09:00 -0800
                  Re: How can I overwrite existing files with new input to running Ghostscript?. Ernie Kent <ernie@erniekent.com> - 2012-12-22 19:37 -0800
                    Re: How can I overwrite existing files with new input to running Ghostscript?. Chris <cjl@spamcop.net> - 2012-12-23 17:16 +0000
                    Re: How can I overwrite existing files with new input to running Ghostscript?. SaGS <sags5495@gmail.com> - 2012-12-23 10:16 -0800
                      Re: How can I overwrite existing files with new input to running Ghostscript?. luser- -droog <mijoryx@yahoo.com> - 2012-12-24 19:37 -0800

Page 1 of 2  [1] 2  Next page →


#1159 — How can I overwrite existing files with new input to running Ghostscript?.

FromErnie Kent <ernie@erniekent.com>
Date2012-12-09 10:14 -0800
SubjectHow can I overwrite existing files with new input to running Ghostscript?.
Message-ID<f6b4b79d-2be2-419a-be53-630ffe54dc66@googlegroups.com>
I need Ghostscript to repeatedly write small, jpg images rapidly to the same file from PS or EPS input on STDIN. Once Ghostscript is up and running it takes an acceptable time to create my images. However, to repeatedly start Ghostscript and have it do the same job, quit and restart again is taking too long. I need to understand how to get Ghostscript to write a Postscript page to a jpg file, stay running and accept another Postscript page description from STDIN, write that to the same file, overwriting the first, and repeat that cycle indefinitely until told to quit. (This is all on a Linux machine by the way.)

I've been knocking my head against this, and finding the documentation not very helpful. The -dJOBSERVER switch looks like it should do something like the desired operation but I can't get it to. Can you give me any help to get on the right track?

[toc] | [next] | [standalone]


#1160

FromHelge Blischke <h.blischke@acm.org>
Date2012-12-09 22:13 +0100
Message-ID<aikd7fFr4h9U1@mid.individual.net>
In reply to#1159
Ernie Kent wrote:

> I need Ghostscript to repeatedly write small, jpg images rapidly to the
> same file from PS or EPS input on STDIN. Once Ghostscript is up and
> running it takes an acceptable time to create my images. However, to
> repeatedly start Ghostscript and have it do the same job, quit and restart
> again is taking too long. I need to understand how to get Ghostscript to
> write a Postscript page to a jpg file, stay running and accept another
> Postscript page description from STDIN, write that to the same file,
> overwriting the first, and repeat that cycle indefinitely until told to
> quit. (This is all on a Linux machine by the way.)
> 
> I've been knocking my head against this, and finding the documentation not
> very helpful. The -dJOBSERVER switch looks like it should do something
> like the desired operation but I can't get it to. Can you give me any help
> to get on the right track?

Look at the device parameter
OutputFile <string>
which can be used as a key / value pair in the pagedevice dictionary.
Depending on how your input is irganized, you may need to intercept showpage 
to close the current output file and open a new one.

Helge

[toc] | [prev] | [next] | [standalone]


#1161

FromErnie Kent <ernie@erniekent.com>
Date2012-12-09 13:52 -0800
Message-ID<9ae6d1f7-5146-430f-b1f1-75d8d64fd86c@googlegroups.com>
In reply to#1160
On Sunday, December 9, 2012 4:13:17 PM UTC-5, Helge Blischke wrote:
> Ernie Kent wrote:
> 
> 
> 
> > I need Ghostscript to repeatedly write small, jpg images rapidly to the
> 
> > same file from PS or EPS input on STDIN. Once Ghostscript is up and
> 
> > running it takes an acceptable time to create my images. However, to
> 
> > repeatedly start Ghostscript and have it do the same job, quit and restart
> 
> > again is taking too long. I need to understand how to get Ghostscript to
> 
> > write a Postscript page to a jpg file, stay running and accept another
> 
> > Postscript page description from STDIN, write that to the same file,
> 
> > overwriting the first, and repeat that cycle indefinitely until told to
> 
> > quit. (This is all on a Linux machine by the way.)
> 
> > 
> 
> > I've been knocking my head against this, and finding the documentation not
> 
> > very helpful. The -dJOBSERVER switch looks like it should do something
> 
> > like the desired operation but I can't get it to. Can you give me any help
> 
> > to get on the right track?
> 
> 
> 
> Look at the device parameter
> 
> OutputFile <string>
> 
> which can be used as a key / value pair in the pagedevice dictionary.
> 
> Depending on how your input is irganized, you may need to intercept showpage 
> 
> to close the current output file and open a new one.
> 
> 
> 
> Helge

Thanks. Since I want to write over the same file each time, I assume I'd just leave the string alone, but you're saying I would need to close the file before writing another page over it? Can you point me to some information on how to do that?
Ernie

[toc] | [prev] | [next] | [standalone]


#1162

From"luser.droog" <luser.droog@gmail.com>
Date2012-12-09 18:28 -0600
Message-ID<ka3ac1$ehv$1@dont-email.me>
In reply to#1161
Ernie Kent wrote:

> On Sunday, December 9, 2012 4:13:17 PM UTC-5, Helge Blischke wrote:
>> Ernie Kent wrote:
>> 
>> 
>> 
>> > I need Ghostscript to repeatedly write small, jpg images rapidly to the
>> 
>> > same file from PS or EPS input on STDIN. Once Ghostscript is up and
>> 
>> > running it takes an acceptable time to create my images. However, to
>> 
>> > repeatedly start Ghostscript and have it do the same job, quit and
>> > restart
>> 
>> > again is taking too long. I need to understand how to get Ghostscript
>> > to
>> 
>> > write a Postscript page to a jpg file, stay running and accept another
>> 
>> > Postscript page description from STDIN, write that to the same file,
>> 
>> > overwriting the first, and repeat that cycle indefinitely until told to
>> 
>> > quit. (This is all on a Linux machine by the way.)
>> 
>> > 
>> 
>> > I've been knocking my head against this, and finding the documentation
>> > not
>> 
>> > very helpful. The -dJOBSERVER switch looks like it should do something
>> 
>> > like the desired operation but I can't get it to. Can you give me any
>> > help
>> 
>> > to get on the right track?
>> 
>> 
>> 
>> Look at the device parameter
>> 
>> OutputFile <string>
>> 
>> which can be used as a key / value pair in the pagedevice dictionary.
>> 
>> Depending on how your input is irganized, you may need to intercept
>> showpage
>> 
>> to close the current output file and open a new one.
>> 
>> 
>> 
>> Helge
> 
> Thanks. Since I want to write over the same file each time, I assume I'd
> just leave the string alone, but you're saying I would need to close the
> file before writing another page over it? Can you point me to some
> information on how to do that? Ernie

That's the crux of the issue. If you're running the interpreter
continuously, "each time" needs more precise definition.
Normally, writing and closing a file makes the data available to other
processes through the filename. But if it stays open, when should (can)
others access the data? Simply in order to rewind the file in postscript
you need to

  File closefile
  /File Filename (r) file def

That is, close it and open it again.

[toc] | [prev] | [next] | [standalone]


#1163

FromErnie Kent <ernie@erniekent.com>
Date2012-12-09 17:11 -0800
Message-ID<287fe534-1fd4-458a-85ab-679b1ebd278c@googlegroups.com>
In reply to#1162
On Sunday, December 9, 2012 7:28:47 PM UTC-5, luser- -droog wrote:
> Ernie Kent wrote:
> 
> 
> 
> > On Sunday, December 9, 2012 4:13:17 PM UTC-5, Helge Blischke wrote:
> 
> >> Ernie Kent wrote:
> 
> >> 
> 
> >> 
> 
> >> 
> 
> >> > I need Ghostscript to repeatedly write small, jpg images rapidly to the
> 
> >> 
> 
> >> > same file from PS or EPS input on STDIN. Once Ghostscript is up and
> 
> >> 
> 
> >> > running it takes an acceptable time to create my images. However, to
> 
> >> 
> 
> >> > repeatedly start Ghostscript and have it do the same job, quit and
> 
> >> > restart
> 
> >> 
> 
> >> > again is taking too long. I need to understand how to get Ghostscript
> 
> >> > to
> 
> >> 
> 
> >> > write a Postscript page to a jpg file, stay running and accept another
> 
> >> 
> 
> >> > Postscript page description from STDIN, write that to the same file,
> 
> >> 
> 
> >> > overwriting the first, and repeat that cycle indefinitely until told to
> 
> >> 
> 
> >> > quit. (This is all on a Linux machine by the way.)
> 
> >> 
> 
> >> > 
> 
> >> 
> 
> >> > I've been knocking my head against this, and finding the documentation
> 
> >> > not
> 
> >> 
> 
> >> > very helpful. The -dJOBSERVER switch looks like it should do something
> 
> >> 
> 
> >> > like the desired operation but I can't get it to. Can you give me any
> 
> >> > help
> 
> >> 
> 
> >> > to get on the right track?
> 
> >> 
> 
> >> 
> 
> >> 
> 
> >> Look at the device parameter
> 
> >> 
> 
> >> OutputFile <string>
> 
> >> 
> 
> >> which can be used as a key / value pair in the pagedevice dictionary.
> 
> >> 
> 
> >> Depending on how your input is irganized, you may need to intercept
> 
> >> showpage
> 
> >> 
> 
> >> to close the current output file and open a new one.
> 
> >> 
> 
> >> 
> 
> >> 
> 
> >> Helge
> 
> > 
> 
> > Thanks. Since I want to write over the same file each time, I assume I'd
> 
> > just leave the string alone, but you're saying I would need to close the
> 
> > file before writing another page over it? Can you point me to some
> 
> > information on how to do that? Ernie
> 
> 
> 
> That's the crux of the issue. If you're running the interpreter
> 
> continuously, "each time" needs more precise definition.
> 
> Normally, writing and closing a file makes the data available to other
> 
> processes through the filename. But if it stays open, when should (can)
> 
> others access the data? Simply in order to rewind the file in postscript
> 
> you need to
> 
> 
> 
>   File closefile
> 
>   /File Filename (r) file def
> 
> 
> 
> That is, close it and open it again.

Thanks. To be more precise about "each time", what I need to do is start Ghostscript once at the beginning of a user's web session and then generate a new image each time I receive new input from the user's browser by creating some new postscript and sending it to Ghostcript to output as a jpeg. I need to write this image immediately to the same, named output file and then notify the user's browser to reload it in an iframe. The updates will be rapid so I can't afford to restart Ghostscript on each update of the image, and I can't afford to generate multiple images at that rate, so I need to keep overwriting the same image.
Ernie

[toc] | [prev] | [next] | [standalone]


#1164

FromSaGS <sags5495@gmail.com>
Date2012-12-09 20:24 -0800
Message-ID<ad22b3d0-18b1-477b-a5e4-2172c52da893@n8g2000vbb.googlegroups.com>
In reply to#1159
On Dec 9, 8:14 pm, Ernie Kent <er...@erniekent.com> wrote:
> I need Ghostscript to repeatedly write small, jpg images rapidly to the same file
> from PS or EPS input on STDIN. Once Ghostscript is up and running it takes an
> acceptable time to create my images. However, to repeatedly start Ghostscript and
> have it do the same job, quit and restart again is taking too long.

A way to do it: for each file do a "save", setup and install the
output device, run the input PS file, "restore".

For the "setup and install the output device" step you need some GS-
specific operators. Look into Ghostscript's Language.htm for
"findprotodevice", "copydevice", "putdeviceprops", and
"setdevice" (call them in this order, with appropriate parameters).

> ...
> The -dJOBSERVER switch looks like it should do something like the desired operation
> but I can't get it to.
> ...

I think -dJOBSERVER does not work because you want the same output
filename. The device does not change, so GS does not close the old
device (so no finishing/ closing of the output file) and create a new
one.

[toc] | [prev] | [next] | [standalone]


#1165

FromErnie Kent <ernie@erniekent.com>
Date2012-12-10 07:00 -0800
Message-ID<041fe8a8-8511-4ebe-9725-de32a207bf94@googlegroups.com>
In reply to#1164
On Sunday, December 9, 2012 11:24:54 PM UTC-5, SaGS wrote:
> On Dec 9, 8:14 pm, Ernie Kent <er...@erniekent.com> wrote:
> 
> > I need Ghostscript to repeatedly write small, jpg images rapidly to the same file
> 
> > from PS or EPS input on STDIN. Once Ghostscript is up and running it takes an
> 
> > acceptable time to create my images. However, to repeatedly start Ghostscript and
> 
> > have it do the same job, quit and restart again is taking too long.
> 
> 
> 
> A way to do it: for each file do a "save", setup and install the
> 
> output device, run the input PS file, "restore".
> 
> 
> 
> For the "setup and install the output device" step you need some GS-
> 
> specific operators. Look into Ghostscript's Language.htm for
> 
> "findprotodevice", "copydevice", "putdeviceprops", and
> 
> "setdevice" (call them in this order, with appropriate parameters).
> 
> 
> 
> > ...
> 
> > The -dJOBSERVER switch looks like it should do something like the desired operation
> 
> > but I can't get it to.
> 
> > ...
> 
> 
> 
> I think -dJOBSERVER does not work because you want the same output
> 
> filename. The device does not change, so GS does not close the old
> 
> device (so no finishing/ closing of the output file) and create a new
> 
> one.

Thanks, I'm investigating this.

Ernie

[toc] | [prev] | [next] | [standalone]


#1166

FromErnie Kent <ernie@erniekent.com>
Date2012-12-10 12:39 -0800
Message-ID<0e14a777-cf2e-4b25-bb31-2892d3e918ff@googlegroups.com>
In reply to#1165
On Monday, December 10, 2012 10:00:04 AM UTC-5, Ernie Kent wrote:
> On Sunday, December 9, 2012 11:24:54 PM UTC-5, SaGS wrote:
> 
> > On Dec 9, 8:14 pm, Ernie Kent <er...@erniekent.com> wrote:
> 
> > 
> 
> > > I need Ghostscript to repeatedly write small, jpg images rapidly to the same file
> 
> > 
> 
> > > from PS or EPS input on STDIN. Once Ghostscript is up and running it takes an
> 
> > 
> 
> > > acceptable time to create my images. However, to repeatedly start Ghostscript and
> 
> > 
> 
> > > have it do the same job, quit and restart again is taking too long.
> 
> > 
> 
> > 
> 
> > 
> 
> > A way to do it: for each file do a "save", setup and install the
> 
> > 
> 
> > output device, run the input PS file, "restore".
> 
> > 
> 
> > 
> 
> > 
> 
> > For the "setup and install the output device" step you need some GS-
> 
> > 
> 
> > specific operators. Look into Ghostscript's Language.htm for
> 
> > 
> 
> > "findprotodevice", "copydevice", "putdeviceprops", and
> 
> > 
> 
> > "setdevice" (call them in this order, with appropriate parameters).
> 
> > 
> 
> > 
> 
> > 
> 
> > > ...
> 
> > 
> 
> > > The -dJOBSERVER switch looks like it should do something like the desired operation
> 
> > 
> 
> > > but I can't get it to.
> 
> > 
> 
> > > ...
> 
> > 
> 
> > 
> 
> > 
> 
> > I think -dJOBSERVER does not work because you want the same output
> 
> > 
> 
> > filename. The device does not change, so GS does not close the old
> 
> > 
> 
> > device (so no finishing/ closing of the output file) and create a new
> 
> > 
> 
> > one.
> 
> 
> 
> Thanks, I'm investigating this.
> 
> 
> 
> Ernie

I am not having much luck with any of these solutions, most likely because There are problems with my syntax; I'm having difficulty finding concrete examples. Can anyone show me a short example?
Thanks, Ernie

[toc] | [prev] | [next] | [standalone]


#1167

FromChris <cjl@spamcop.net>
Date2012-12-11 10:12 +0000
Message-ID<_FDxs.680719$YJ1.480435@fx09.am4>
In reply to#1166
On Mon, 10 Dec 2012 12:39:30 -0800, Ernie Kent wrote:
> 
> I am not having much luck with any of these solutions, most likely
> because There are problems with my syntax; I'm having difficulty finding
> concrete examples. Can anyone show me a short example?
> Thanks, Ernie

If all you want to do really is to overwrite the same file again and 
again, just don't give gs the "format" part of the file names we normally 
use - so instead of something like "myfile%03d.jpg", give it "myfile.jpg" 
for the output file name.

Without the "%03d" marker, there is nowhere for GS to store the "index" 
so it doesn't.

NOTE: this will *not* work for formats like TIFF which have multipage 
support (and multipage support is implemented in Ghostscript). For those 
formats, leaving off the format marker in the file name will result a 
single multipage file.

And, of course, I assume you don't have to worry about multipage 
Postscript files....

Chris

[toc] | [prev] | [next] | [standalone]


#1169

FromErnie Kent <ernie@erniekent.com>
Date2012-12-11 11:04 -0800
Message-ID<ff352dee-a18d-4f75-b0ba-4bb3654e825e@googlegroups.com>
In reply to#1167
On Tuesday, December 11, 2012 5:12:10 AM UTC-5, Chris wrote:
> On Mon, 10 Dec 2012 12:39:30 -0800, Ernie Kent wrote:
> 
> > 
> 
> > I am not having much luck with any of these solutions, most likely
> 
> > because There are problems with my syntax; I'm having difficulty finding
> 
> > concrete examples. Can anyone show me a short example?
> 
> > Thanks, Ernie
> 
> 
> 
> If all you want to do really is to overwrite the same file again and 
> 
> again, just don't give gs the "format" part of the file names we normally 
> 
> use - so instead of something like "myfile%03d.jpg", give it "myfile.jpg" 
> 
> for the output file name.
> 
> 
> 
> Without the "%03d" marker, there is nowhere for GS to store the "index" 
> 
> so it doesn't.
> 
> 
> 
> NOTE: this will *not* work for formats like TIFF which have multipage 
> 
> support (and multipage support is implemented in Ghostscript). For those 
> 
> formats, leaving off the format marker in the file name will result a 
> 
> single multipage file.
> 
> 
> 
> And, of course, I assume you don't have to worry about multipage 
> 
> Postscript files....
> 
> 
> 
> Chris

Not quite clear on that -- I have been using -sOutputFile-test,jpg which looks like what you seem to be recommending.
Ernie

[toc] | [prev] | [next] | [standalone]


#1172

FromChris <cjl@spamcop.net>
Date2012-12-12 07:41 +0000
Message-ID<NyWxs.682072$YJ1.69700@fx09.am4>
In reply to#1169
On Tue, 11 Dec 2012 11:04:53 -0800, Ernie Kent wrote:

> 
> Not quite clear on that -- I have been using -sOutputFile-test,jpg which
> looks like what you seem to be recommending.

I assume that's a typo, and it's "-sOutputFile=test.jpg".

In which case, each page should be written to the test.jpg file, 
overwriting the previous contents of the file, which I understood is what 
you want.

Chris

[toc] | [prev] | [next] | [standalone]


#1173

FromSaGS <sags5495@gmail.com>
Date2012-12-12 03:52 -0800
Message-ID<ed943cc7-454e-4b72-9dde-7d3b80fdcb51@w3g2000yqj.googlegroups.com>
In reply to#1172
On Dec 12, 9:41 am, Chris <c...@spamcop.net> wrote:
> ...
> I assume that's a typo, and it's "-sOutputFile=test.jpg".
>
> In which case, each page should be written to the test.jpg file,
> overwriting the previous contents of the file, which I understood is what
> you want.
> ...

I'm not the OP, but...

As I understand it, your idea is to feed GS a multipage PS stream and
get one output file per PAGE. For me the jpeg device produces, if
given multi-page PS input with -sOutputFile=without_percent_something,
a single output file that contains the 1st page only; the rest of the
pages are lost. I have not looked specifically at how the jpeg device
works, but see base\gsdevice.c::gx_outputfile_is_separate_pages() and
base\gsdevice.c::gx_parse_output_file_name().

However, your idea can be (ab)used :) to get what the OP wants: -
sOutputFile=%d/../fixed.jpg.

This triggers GS's "one output file per page" logic AND each time the
output file will be the same. Windows at least does not care that
directories that are "canceled" with "..\" do not exist. For example
"C:\TEMP\Missing\..\file.jpg" is handled exactly as "C:\TEMP
\file.jpg", ignoring weather a "C:\TEMP\Missing" directory exists or
not.

[toc] | [prev] | [next] | [standalone]


#1174

FromChris <cjl@spamcop.net>
Date2012-12-12 12:52 +0000
Message-ID<66%xs.503291$Wc4.208260@fx10.am4>
In reply to#1173
On Wed, 12 Dec 2012 03:52:11 -0800, SaGS wrote:

> I'm not the OP, but...
> 
> As I understand it, your idea is to feed GS a multipage PS stream and
> get one output file per PAGE. For me the jpeg device produces, if given
> multi-page PS input with -sOutputFile=without_percent_something,
> a single output file that contains the 1st page only; the rest of the
> pages are lost. I have not looked specifically at how the jpeg device
> works, but see base\gsdevice.c::gx_outputfile_is_separate_pages() and
> base\gsdevice.c::gx_parse_output_file_name().


Well, I did specifically say: "And, of course, I assume you don't have to 
worry about multipage Postscript files...."

Chris

[toc] | [prev] | [next] | [standalone]


#1175

FromErnie Kent <ernie@erniekent.com>
Date2012-12-12 08:45 -0800
Message-ID<4358520d-6d04-4c65-934d-711eaa80b08e@googlegroups.com>
In reply to#1174
On Wednesday, December 12, 2012 7:52:18 AM UTC-5, Chris wrote:
> On Wed, 12 Dec 2012 03:52:11 -0800, SaGS wrote:
> 
> 
> 
> > I'm not the OP, but...
> 
> > 
> 
> > As I understand it, your idea is to feed GS a multipage PS stream and
> 
> > get one output file per PAGE. For me the jpeg device produces, if given
> 
> > multi-page PS input with -sOutputFile=without_percent_something,
> 
> > a single output file that contains the 1st page only; the rest of the
> 
> > pages are lost. I have not looked specifically at how the jpeg device
> 
> > works, but see base\gsdevice.c::gx_outputfile_is_separate_pages() and
> 
> > base\gsdevice.c::gx_parse_output_file_name().
> 
> 
> 
> 
> 
> Well, I did specifically say: "And, of course, I assume you don't have to 
> 
> worry about multipage Postscript files...."
> 
> 
> 
> Chris

Chris and SaGS: 
Yes, it was a typo, should have been '='. However it does not give the desired result, which is to overwrite the single page output file with each new page of input, without having to reload GS. Basically, it's a web application where I feed back modified images of text as users feed parameters to the server. So with each new input parameter they get a new, modified jpg back. It has to run fast so reloading GS each time is not an option. SaGS's example script seems to do the trick. Thanks to all for the help!
Ernie

[toc] | [prev] | [next] | [standalone]


#1176

FromChris <cjl@spamcop.net>
Date2012-12-13 14:07 +0000
Message-ID<xilys.689977$9D6.508848@fx27.am4>
In reply to#1175
On Wed, 12 Dec 2012 08:45:13 -0800, Ernie Kent wrote:

> 
> Chris and SaGS:
> Yes, it was a typo, should have been '='. However it does not give the
> desired result, which is to overwrite the single page output file with
> each new page of input, without having to reload GS.

Yeh, sorry, the non-number-pattern operation doesn't work as I thought, 
it's certainly not how I'd have written it....

Chris

[toc] | [prev] | [next] | [standalone]


#1168

FromSaGS <sags5495@gmail.com>
Date2012-12-11 02:44 -0800
Message-ID<1a56d555-9213-4d7a-a7fd-2352372e79ed@k6g2000yqf.googlegroups.com>
In reply to#1166
On Dec 10, 10:39 pm, Ernie Kent <er...@erniekent.com> wrote:
> ...
> I am not having much luck with any of these solutions, most likely because There
> are problems with my syntax; I'm having difficulty finding concrete examples.
> Can anyone show me a short example?
> ...

Here's a proof-of-concept for the "create the same output file
multiple times" part, the "sync with the caller/ web server" is up to
you:

% CUT HERE -- 8< ----- 8< ----- 8< ----- 8< ----- 8< ----- 8< ----- 8<
--

% Test with:
%
%     gswin32c -dBATCH -dNOPAUSE -sDEVICE=nullpage this.ps
%
% (on Windows, for other platforms use the appropriate executable
name)
% Of course you need to somehow pause between "files", to examine each
% instance of the output.

% Utility procedure

/SetMyDevice { % This is the "setup and install the output device"
step
    [
        /OutputFile (out.jpg)
        % Key-value pairs for other device params go here
        % - as an example, we set params for a 2"x1" 256x128pixel
        %   antialiased image
        /HWResolution [128 128]
        /PageSize [144 72]
        /TextAlphaBits 4
        /GraphicsAlphaBits 4
    /jpeg findprotodevice copydevice putdeviceprops setdevice
} bind def

% For the 1st "input file"
userdict /MyFiLeLeVeLsAvE save put
    SetMyDevice
    % here we draw something
        /Times-Bold 20 selectfont
        3 10 moveto
        (1st piece of Text) show
        showpage
    % end of drawing operations
cleardictstack clear MyFiLeLeVeLsAvE restore

% At this point, the 1st jpeg is ready
(1st jpeg is ready...) = flush
% Passing to the next...

% For the 2nd "input file"
userdict /MyFiLeLeVeLsAvE save put
    SetMyDevice
    % here we draw something
        /Times-Bold 16 selectfont
        2 10 moveto
        (Second piece of Text) show
        showpage
    % end of drawing operations
cleardictstack clear MyFiLeLeVeLsAvE restore

% At this point, the 2nd jpeg is ready
(2nd jpeg is ready...) = flush
% and so on...
% CUT HERE -- 8< ----- 8< ----- 8< ----- 8< ----- 8< ----- 8< ----- 8<
--

[toc] | [prev] | [next] | [standalone]


#1170

FromErnie Kent <ernie@erniekent.com>
Date2012-12-11 11:05 -0800
Message-ID<4fe8d873-776f-4d95-8f5f-37326b98cb83@googlegroups.com>
In reply to#1168
On Tuesday, December 11, 2012 5:44:51 AM UTC-5, SaGS wrote:
> On Dec 10, 10:39 pm, Ernie Kent <er...@erniekent.com> wrote:
> 
> > ...
> 
> > I am not having much luck with any of these solutions, most likely because There
> 
> > are problems with my syntax; I'm having difficulty finding concrete examples.
> 
> > Can anyone show me a short example?
> 
> > ...
> 
> 
> 
> Here's a proof-of-concept for the "create the same output file
> 
> multiple times" part, the "sync with the caller/ web server" is up to
> 
> you:
> 
> 
> 
> % CUT HERE -- 8< ----- 8< ----- 8< ----- 8< ----- 8< ----- 8< ----- 8<
> 
> --
> 
> 
> 
> % Test with:
> 
> %
> 
> %     gswin32c -dBATCH -dNOPAUSE -sDEVICE=nullpage this.ps
> 
> %
> 
> % (on Windows, for other platforms use the appropriate executable
> 
> name)
> 
> % Of course you need to somehow pause between "files", to examine each
> 
> % instance of the output.
> 
> 
> 
> % Utility procedure
> 
> 
> 
> /SetMyDevice { % This is the "setup and install the output device"
> 
> step
> 
>     [
> 
>         /OutputFile (out.jpg)
> 
>         % Key-value pairs for other device params go here
> 
>         % - as an example, we set params for a 2"x1" 256x128pixel
> 
>         %   antialiased image
> 
>         /HWResolution [128 128]
> 
>         /PageSize [144 72]
> 
>         /TextAlphaBits 4
> 
>         /GraphicsAlphaBits 4
> 
>     /jpeg findprotodevice copydevice putdeviceprops setdevice
> 
> } bind def
> 
> 
> 
> % For the 1st "input file"
> 
> userdict /MyFiLeLeVeLsAvE save put
> 
>     SetMyDevice
> 
>     % here we draw something
> 
>         /Times-Bold 20 selectfont
> 
>         3 10 moveto
> 
>         (1st piece of Text) show
> 
>         showpage
> 
>     % end of drawing operations
> 
> cleardictstack clear MyFiLeLeVeLsAvE restore
> 
> 
> 
> % At this point, the 1st jpeg is ready
> 
> (1st jpeg is ready...) = flush
> 
> % Passing to the next...
> 
> 
> 
> % For the 2nd "input file"
> 
> userdict /MyFiLeLeVeLsAvE save put
> 
>     SetMyDevice
> 
>     % here we draw something
> 
>         /Times-Bold 16 selectfont
> 
>         2 10 moveto
> 
>         (Second piece of Text) show
> 
>         showpage
> 
>     % end of drawing operations
> 
> cleardictstack clear MyFiLeLeVeLsAvE restore
> 
> 
> 
> % At this point, the 2nd jpeg is ready
> 
> (2nd jpeg is ready...) = flush
> 
> % and so on...
> 
> % CUT HERE -- 8< ----- 8< ----- 8< ----- 8< ----- 8< ----- 8< ----- 8<
> 
> --

SaGS - thank you very much for that. I will get to work on it.
Ernie

[toc] | [prev] | [next] | [standalone]


#1171

FromErnie Kent <ernie@erniekent.com>
Date2012-12-11 12:37 -0800
Message-ID<00199c10-d33f-473b-909a-6f24cebdea9f@googlegroups.com>
In reply to#1168
On Tuesday, December 11, 2012 5:44:51 AM UTC-5, SaGS wrote:
> On Dec 10, 10:39 pm, Ernie Kent <er...@erniekent.com> wrote:
> 
> > ...
> 
> > I am not having much luck with any of these solutions, most likely because There
> 
> > are problems with my syntax; I'm having difficulty finding concrete examples.
> 
> > Can anyone show me a short example?
> 
> > ...
> 
> 
> 
> Here's a proof-of-concept for the "create the same output file
> 
> multiple times" part, the "sync with the caller/ web server" is up to
> 
> you:
> 
> 
> 
> % CUT HERE -- 8< ----- 8< ----- 8< ----- 8< ----- 8< ----- 8< ----- 8<
> 
> --
> 
> 
> 
> % Test with:
> 
> %
> 
> %     gswin32c -dBATCH -dNOPAUSE -sDEVICE=nullpage this.ps
> 
> %
> 
> % (on Windows, for other platforms use the appropriate executable
> 
> name)
> 
> % Of course you need to somehow pause between "files", to examine each
> 
> % instance of the output.
> 
> 
> 
> % Utility procedure
> 
> 
> 
> /SetMyDevice { % This is the "setup and install the output device"
> 
> step
> 
>     [
> 
>         /OutputFile (out.jpg)
> 
>         % Key-value pairs for other device params go here
> 
>         % - as an example, we set params for a 2"x1" 256x128pixel
> 
>         %   antialiased image
> 
>         /HWResolution [128 128]
> 
>         /PageSize [144 72]
> 
>         /TextAlphaBits 4
> 
>         /GraphicsAlphaBits 4
> 
>     /jpeg findprotodevice copydevice putdeviceprops setdevice
> 
> } bind def
> 
> 
> 
> % For the 1st "input file"
> 
> userdict /MyFiLeLeVeLsAvE save put
> 
>     SetMyDevice
> 
>     % here we draw something
> 
>         /Times-Bold 20 selectfont
> 
>         3 10 moveto
> 
>         (1st piece of Text) show
> 
>         showpage
> 
>     % end of drawing operations
> 
> cleardictstack clear MyFiLeLeVeLsAvE restore
> 
> 
> 
> % At this point, the 1st jpeg is ready
> 
> (1st jpeg is ready...) = flush
> 
> % Passing to the next...
> 
> 
> 
> % For the 2nd "input file"
> 
> userdict /MyFiLeLeVeLsAvE save put
> 
>     SetMyDevice
> 
>     % here we draw something
> 
>         /Times-Bold 16 selectfont
> 
>         2 10 moveto
> 
>         (Second piece of Text) show
> 
>         showpage
> 
>     % end of drawing operations
> 
> cleardictstack clear MyFiLeLeVeLsAvE restore
> 
> 
> 
> % At this point, the 2nd jpeg is ready
> 
> (2nd jpeg is ready...) = flush
> 
> % and so on...
> 
> % CUT HERE -- 8< ----- 8< ----- 8< ----- 8< ----- 8< ----- 8< ----- 8<
> 
> --

SaGS, 
Works like a charm! Many thanks; it would've taken me a year to figure that out! :)

[toc] | [prev] | [next] | [standalone]


#1181

FromErnie Kent <ernie@erniekent.com>
Date2012-12-21 21:40 -0800
Message-ID<d4fef961-6eb2-4dac-8ffc-b89cc679297d@googlegroups.com>
In reply to#1168
On Tuesday, December 11, 2012 5:44:51 AM UTC-5, SaGS wrote:
> On Dec 10, 10:39 pm, Ernie Kent <er...@erniekent.com> wrote:
> 
> > ...
> 
> > I am not having much luck with any of these solutions, most likely because There
> 
> > are problems with my syntax; I'm having difficulty finding concrete examples.
> 
> > Can anyone show me a short example?
> 
> > ...
> 
> 
> 
> Here's a proof-of-concept for the "create the same output file
> 
> multiple times" part, the "sync with the caller/ web server" is up to
> 
> you:
> 
> 
> 
> % CUT HERE -- 8< ----- 8< ----- 8< ----- 8< ----- 8< ----- 8< ----- 8<
> 
> --
> 
> 
> 
> % Test with:
> 
> %
> 
> %     gswin32c -dBATCH -dNOPAUSE -sDEVICE=nullpage this.ps
> 
> %
> 
> % (on Windows, for other platforms use the appropriate executable
> 
> name)
> 
> % Of course you need to somehow pause between "files", to examine each
> 
> % instance of the output.
> 
> 
> 
> % Utility procedure
> 
> 
> 
> /SetMyDevice { % This is the "setup and install the output device"
> 
> step
> 
>     [
> 
>         /OutputFile (out.jpg)
> 
>         % Key-value pairs for other device params go here
> 
>         % - as an example, we set params for a 2"x1" 256x128pixel
> 
>         %   antialiased image
> 
>         /HWResolution [128 128]
> 
>         /PageSize [144 72]
> 
>         /TextAlphaBits 4
> 
>         /GraphicsAlphaBits 4
> 
>     /jpeg findprotodevice copydevice putdeviceprops setdevice
> 
> } bind def
> 
> 
> 
> % For the 1st "input file"
> 
> userdict /MyFiLeLeVeLsAvE save put
> 
>     SetMyDevice
> 
>     % here we draw something
> 
>         /Times-Bold 20 selectfont
> 
>         3 10 moveto
> 
>         (1st piece of Text) show
> 
>         showpage
> 
>     % end of drawing operations
> 
> cleardictstack clear MyFiLeLeVeLsAvE restore
> 
> 
> 
> % At this point, the 1st jpeg is ready
> 
> (1st jpeg is ready...) = flush
> 
> % Passing to the next...
> 
> 
> 
> % For the 2nd "input file"
> 
> userdict /MyFiLeLeVeLsAvE save put
> 
>     SetMyDevice
> 
>     % here we draw something
> 
>         /Times-Bold 16 selectfont
> 
>         2 10 moveto
> 
>         (Second piece of Text) show
> 
>         showpage
> 
>     % end of drawing operations
> 
> cleardictstack clear MyFiLeLeVeLsAvE restore
> 
> 
> 
> % At this point, the 2nd jpeg is ready
> 
> (2nd jpeg is ready...) = flush
> 
> % and so on...
> 
> % CUT HERE -- 8< ----- 8< ----- 8< ----- 8< ----- 8< ----- 8< ----- 8<
> 
> --

SaGS, I am having one problem with this. Although it overwrites the output, it doesn't actually change the file until GS is terminated. Thus I have a GS process that is continually taking input and overwriting the output to the device with new images, but other processes can't see them until GS closes, whereupon the last one is actually written out. 

I've tried using both flushfile and closefile after showpage in your routine, but I can't find a way to specify the outputfile to these operators that doesn't give an error. Thanks for any help.

Ernie

[toc] | [prev] | [next] | [standalone]


#1183

FromSaGS <sags5495@gmail.com>
Date2012-12-22 00:53 -0800
Message-ID<a66bd6a2-8b88-4ffa-ae40-b2702b88b6e3@r13g2000vbd.googlegroups.com>
In reply to#1181
On 22 dec., 07:40, Ernie Kent <er...@erniekent.com> wrote:
> ...
> Although it overwrites the output, it doesn't actually change the file
> until GS is terminated.
> ...
> I've tried using both flushfile and closefile after showpage in your routine,
> but I can't find a way to specify the outputfile to these operators that
> doesn't give an error.
> ...

The output file is available after the "restore" (there where I
inserted code to print a message), the "showpage" in not sufficient.
This is what should happen, and on Windows at least this is actually
happening (I even used the Process Monitor and seen it closes the
file); I cannot try on Linux.

I don't know how you sync your program and GS, but in case you expect
to have the output file available when GS sends the ">>showpage, press
<return> to continue<<" message that's certainly not OK.

[toc] | [prev] | [next] | [standalone]


Page 1 of 2  [1] 2  Next page →

Back to top | Article view | comp.lang.postscript


csiph-web