Ghostscript Stamp Image on PDF - image

Is there any way to stamp or overlap a tiff image on a existing PDF file and output the result using Ghostscript?
I have two PDF which i want to merge in a result PDF with one over the other using ghostscript. I want to know if this can be done and how, or if it may work with one PDF as tiff image on top of the base PDF.
Can ghostscript make this stamp using layers in the PDF?
Thank you for your answers

The pdfwrite device in Ghostscript doesn't really support layers, so you can't use that. Also its unclear why you think layers would help.
TIFF isn't part of PostScript (or PDF), so you can't directly read a TIFF file into GS. I have elsewhere posted a PostScript program which reads TIFF files and renders them for output. You could use that to read a TIFF file.
However, you would have to mess about with either the PDF interpreter or a custom EndPage procedure in order to read and render the TIFF file. And unless you take specific kinds of action, it will be opaque, which may well not be what you want.
The Ghostscript PDF interpreter doesn't really lend itself to this kind of manipulation, have you considered using pdftk instead ?

Related

Converting multiple Postscript images into an animated gif

I have several postscript images of the form "filename_0001.ps", "filename_0002.ps", etc. I would like to create an animated gif with each of the files as a frame in the animation, but I do not know how I would go about doing that. I have over 500 files that I would like to include in a single gif and would like to avoid creating the animated gif by hand.
I googled around for a bit and found this. At the very bottom it seems to suggest that there is a one line command that can be used to make the gif, but I haven't been able to figure out how to use it in my case.
Any suggestions would be appreciated.
I've used ghostscript and ImageMagick's convert to do this. I used these commands
gs -sDEVICE=png48 -g500x500 -o bezan%03d.png bezanim.ps
convert bezan*.png bezan.gif
to produce this animation for this Codegolf.Stackexchange challenge, where the frames were separate pages of a single postscript program.
You can probably do it with the single command
convert filename_*.ps anim.gif
and convert will shell-out to ghostscript as needed. But for my case, I wanted to specify the arguments to ghostscript directly.

image not shown in dvi after latexing

I include several images of eps format in latex. After latex command, there are some of the images missing in the dvi file. Not sure if it is related to the image size, most of the images missing have size around 83kB while those shown up have a size less than 40kB. After conversion from dvi to ps, the images are all back. Just wonder what is the reason causing the images missing in dvi file?
Thanks and regards!
As far as I can remember, a dvi viewer cannot show eps file. Just use pdflatex as the front-end instead of latex and view the resulting pdf file.
Checking man xdvi reveals this:
Xdvi can show PostScript specials
by any of three methods. It will try
first to use Display PostScript,
then NeWS, then it will try to
use Ghostscript to render the images. All of these options
depend on additional software to work
properly; moreover, some of them may
not be compiled into this copy of xdvi.
So it would appear to be platform- and/or implementation-dependent.

How to modify a .png image with VBScript

I have a need to select a portion of a .png file, with specific cordinators, and delete this area then save the file back with the same name.
I would appreciate if you can help to come up with a VBScript script that can accomplish this task.
It would be great if all proesses happen in the background, but it would be ok too if the image file has to be open and visible. Thanks a bunch!!!
A PNG file, like any other binary file can be edited with CMD or VBS.
A PNG file layout is as follows:
File header
"Chunks" within the file
Pixel format
Transparency of image
Compression
Interlacing
Animation
Read the PNG format in RFC 2083 to know how to edit/create a PNG file at binary/bit level.
To speed up the editing process, libraries are available for application level editing.
Here are some VBA codes for image manipulation.
ImageMagick also provides libraries that can be accessed via VBS for image editing.
Here's a VBScript Image Class for bmp and pcx files (which PNG can be converted to before editing via WIA).
Loadpicture function described here doesn't seem to support PNG, but this discussion might solve it.
The Windows Image Acquisition Library v2.0 supports PNG, BMP, JPG, GIF and TIFF image formats, and comes with Windows Vista and later versions. Sample scripts are available to demonstrate "image manipulation using the ImageFile object". The Vector.ImageFile property also "creates an ImageFile object from raw ARGB data".
More sample codes here & here show how to rotate, flip, scale, crop, etc with WIA Image constants in vbs. To remove unwanted areas of image (with given coordinates), use the crop function.
Here's a discussion of WIA 2.0 image editing on stackoverflow.
VBScript doesn't have any image editing functions, so you need an external tool for that. For example, GIMP can do image processing from the command line (see here). ImageMagick provides a scriptable component in addition to the command-line interface (details here).
To run a command line from a VBScript script, you can use the WShShell.Run method. To create an instance of a COM scriptable component, use the CreateObject function.

PDF to TIFF free library in Windows?

i've got a hundred pages long high quality PDF (66MB) that needs to be converted to TIFF format (300 dpi, as high quality as possible :P).
I've tried Imagemagick/ghostscript, jpedal, Poppler, XPDF but they all produce different results due to the strange gradient of the PDF itself (blame the designers) and some actually take forever....
Does any one know any alternatives that i can try?
Thanks in advance,
M.
The GIMP does a pretty good job reading PDF files. Here's a Windows installer.
The GIMP will load each page of the PDF into its own layer, so you'll have to export each one as a TIFF. Luckily, this can be automated. I have no experience with the linked script, but if it doesn't suit your needs then it shouldn't be hard to modify it or write a quick script of your own to export each layer as a TIFF image.
Try using the Adobe Reader to flatten your PDF to PostScript (newer versions do that from the command line, but since it's just one file, you can print to a PS file) before going through Ghostscript. That might remove some weird PDF issues.

How to convert an image (i.e. pdf) for use in a LaTeX document?

What is the preferred way to convert various images, bitmap and vector, for use in a LaTeX and PDFLaTeX document?
There are many ways to do this, some make use of standard inclusions in the various LaTeX packages, others give better results.
You can include a PDF image directly into a LaTeX document if you want to produce your final output using pdflatex, but not if you want to produce a dvi file.
pdflatex can use PDF, PNG, and JPEG
latex/dvips can use PS, EPS
See more details:
Including images in LaTeX files
Watch what you name graphics files in LaTeX
I convert bitmaps into PNG, and vector graphics (e.g. SVG) into PDF. pdflatex understand both PNG and PDF.
If you have an image "as PDF", and you don't want to include it as pdf, you may want to extract the complete image data first with pdfimages. Other conversions may render the image only with reduced resolution.
My current preferred way is using bmeps and epstopdf included in MikTeX. For the generation of pdf and eps versions of a png.
In a file called convertimage.bat,
bmeps -p3 -c -e8f -tpng %1.png > %1.eps
epstopdf %1.eps
Use by including in the path and writing convertimage.bat filenameminusextension
Include in the documents using,
\begin{figure}[h]
\begin{center}
\includegraphics[scale=0.25]{path/to/fileminuxextension}
\caption{My caption here}
\label{somelabelforreference}
\end{center}
\end{figure}
I only use Encapsulated PostScript (.eps) figures (converting bitmaps with NetPBM first), since I always use dvips + ps2pdf anyway, and then I do \includegraphics{file}.
As John D. Cook says, your available image formats depend on whether you are using latex or pdflatex.
I find ImageMagick a useful tool for converting images between formats. Handles bitmap images, plus ps/pdf/eps (with ghostscript) and a zillion others. Available through apt, macports, etc.
I use a mac so I use GraphicConverter to load images and export as PDFs.
When I draw diagrams, I use Omnigraffle which lets me export as PDFs.
On windows I used to use Visio which supported EPSs which I also had no problems embedding.
The basic issues are that a) you want to handle raster and vector images differently and b) this introduces potential pitfalls.
The "right" thing to do depends a bit on your final output.
If your final output is going to be a .pdf file, and you don't need pstricks or anything else that these days you're probably better off just using pdflatex to directly produce the file.
In this case:
store all vector figures as .pdf
store all raster figures as .png (or jpeg if they were originally jpeg)
use graphicx package and \includegraphics{filename-without-suffix}
If you don't do the above, your raster figures will be converted to jpegs and may gain compression artifacts. png is the best bet if you can choose output.
If you are headed for .dvi file you're going to want .eps for everything. (You can gzip these files as long as you generate a bounding box file).
If you're careful you can do both. I store all vector figures as (compressed) .eps because there are a few things .pdf can't do that .eps can. I store all raster figures as .png. Using make, I can have temporary copies of these canonical versions generated on the fly for .dvi or .pdf output as needed.
Someone above pointed out the filename issue. You want to avoid "." in the file names, and avoid suffixes always in your latex file itself.
I always include images in PNG format.
If you compile your code with pdflatex, then you also can use the \includegraphics to include images in pdf (you have to include the package graphix

Resources