Scripts to convert .ps to other formats and crop    

  • listing of the directory www/bongo/script/
    00readme.html (this file)
    00readme.txt
    bongo2pdf
    crop2pdf2png
    crop2ps2png
    cropbbpdf2png
    croppdf2png
    cropps2png
    pdf2jpg
    pdf2png
    pdf2png-all
    png2pdf
    ps2png

    (the green names are executable scripts normally hosted in the /usr/local/bin/ directory). The "ps2pdf name1.ps name2.pdf" system command is also available and can be used to convert bongo.ps to name.pdf (note that you must provide also the extensions .ps and .pdf).

    This directory contains useful scripts to convert between two image formats. The script names beginning with 'crop' (e.g. croppdf2png, i.e. "convert pdf to png with cropping") need some work in modifying dimension and offsets (-crop nnnnxnnnn+yy+yy), in order to fit the user's preferences: follow the comments within the scripts and try some modification with the help of an image viewer (I use GEEQIE in Linux or GQVIEW in Windows).
    The scripts can be usefully used within a Bongo command file (.bon) to produce the standard output bongo.ps in different formats (I prefer pdf and png, but following the same scheme, it is straightforward to write a script to convert ps or pdf to gif,jpg,tiff ...)

    You can view here a list of all available crop-convert schemas and some comment about them.

    The Bongo code concerning image conversion might be:

    .
    .
    .
    xcol 1
    ycol 2
    ltype 1 18
    connect
    %
    text 5 21
    sreloc 120 340
    label spettri/austria/bohm/t/tmed.bon !writes the Bongo file name at the 
    %                                      bottom-left corner
    id fz   !this line is the "normal" end of a Bongo command file
    %   but in this case the next line are added
    % 4.10.2014: use QUIT to write bongo.ps without exit Bongo
    %     and then:
    %>>1 convert ps to pdf by ps2pdf (ps2pdf bongo.ps name.pdf)
    %>>2 convert, with crop, pdf to png by croppdf2png (croppdf2png name)
    quit        !NOTE: the same as END but beeing yet in Bongo. 
    %            Now bongo.ps has been written and can be converted
    dos ps2pdf bongo.ps tm-aug.pdf ! convert to pdf
    %bongo2pdf tm-aug !(without extension. Better than the above command)
    dos croppdf2png tm-aug         !convert, w/cropping, to png or
    %dos cropbpdf2png tm-aug  !if your plot is tpe "b" or 120x520,400x600 px
    .
    .
    

  • Why do I not crop the pdfs?
    Because pdf viewers can enlarge the image, while png (gif,jpg)s appear too small and ill-defined without cropping.
    NOTE: all the scripts here make use of the ImageMagick command "convert" with or without the -crop parameter. Feel free to change anything (e.g. I use a 200x200 dpi resolution while a 300x300 dpi may be better to your needs; or you do prefer a transparent background instead of the white one I use).
    Page written: October 4, 2014                      Last Update: Nov 17, 2015