Pregunta

I'm working on a script that takes an .xwd image, runs wxdtopnm on it then pipes that to ppmtogif. Basically:

exec wxdtopnm < file.xwd | ppmtogif > file.gif

However, sometimes I get an error

ppmtogiff: to many colors - try doing a 'ppmquant 256'

Well I tried ppmquant and long story short, that option is not avaliable. I stumbled upon pamdepth and want to try that. However, I can find no practical examples on how this is properly used and I'm not exactly an expert in tcl.

I tried

exec wxdtopnm < file.xwd | pamdepth 6 | ppmtogif > file.gif

But that didn't work. I get the message

Error: Invalid Command name "6"

Could someone show an example of how to properly use pamdepth?

¿Fue útil?

Solución

Whatever is going on, it can't be exactly what you wrote:

exec wxdtopnm < file.xwd | pamdepth 6 | ppmtogif > file.gif

When I try doing the equivalent (for our purposes; I don't have any XWD images around):

exec pngtopnm sample.png | pamdepth 6 | ppmtogif >foo.gif

I don't get that error you report. Instead, I get:

pamtogif: computing colormap...
pamtogif: 121 colors found

These are trivial errors caused by the interaction of the fact that pamdepth is chatty on its standard error channel (some programs just are) and the fact that Tcl's exec turns messages on standard error into error messages by default. That's often the right thing, but we don't want it here. But there's a trivial workaround:

exec pngtopnm sample.png | pamdepth 6 2>/dev/null | ppmtogif >foo.gif

This redirects standard error from pamdepth only to the system bit-bucket, leaving the rest of the pipeline to work as expected.

I can't say for sure if this will work for you (I really don't know where that 6 error is coming from!) but it does for me when I try.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top