PDF 2 PNG (300dpi):
gs -sDEVICE=png16m -sOutputFile=output.png -r300 input.pdf
PS 2 PDF:
gs -q -dBATCH -dAutoFilterColorImages=false -sColorImageFilter=FlateEncode -dNOPAUSE -sDEVICE=pdfwrite -sOutputFile=output.pdf input.ps
PDF 2 PNG (300dpi):
gs -sDEVICE=png16m -sOutputFile=output.png -r300 input.pdf
PS 2 PDF:
gs -q -dBATCH -dAutoFilterColorImages=false -sColorImageFilter=FlateEncode -dNOPAUSE -sDEVICE=pdfwrite -sOutputFile=output.pdf input.ps