LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   Is there a command line tool to create images? (https://www.linuxquestions.org/questions/linux-software-2/is-there-a-command-line-tool-to-create-images-173485/)

J_Szucs 04-22-2004 06:26 PM

Is there a command line tool to create images?
 
I wrote a bash script that draws simple diagrams from numeric input data (web traffic averages) using ImageMagick (convert), which works OK.

However, I need a blank image on which the diagram objects will be drawn.
Is it possible to create such a blank image with Image Magick, or some other tools from a bash script?
I want that the script be self-containing, i.e. it should create the image itself.

Thanks in advance.

J_Szucs 04-23-2004 05:20 AM

Some hours of googling and you have the solution...

Here it is with ImageMagick:

> You can create a color image using the XC coder like:
> convert -size 320x200 "xc:#FF0000" red.gif
> where the color format is
> #RRGGBB
> in hex.

Taken from this forum: http://studio.imagemagick.org/piperm...ay/008933.html

cmfarley19 04-23-2004 05:25 AM

I'd be interested in seeing the script you wrote if your willing to share it.

It sounds intriuging.

J_Szucs 11-10-2004 05:57 PM

Sorry, I failed to notice your post.

So, it is not really a script, just two commands:

# Create a blank 120x100 pixels gif image (diagram.gif) with green background for the diagram:
convert -size 120x100 xc:#00FF00 diagram.gif

# Draw a multipoint diagram line using the data in the first column ($1) of the last 120 lines (tail -120) in data.txt.
# The value 50000 below should be replaced by a value equal to <maximum possible value of input data>/100 (because the y dimension of the diagram is 100 pixels in my case)

convert -stroke red -fill none -linewidth 2 -draw "polyline `tail -120 data.txt | awk '{ printf NR "," 100-int($1/50000) " " }'`" diagram.gif diagram.gif

#If your input data file contains, say... one-minute averages, but you want to draw a diagram with say... five minute averages, then you can sum up the data "on the fly" and draw the corresponding diagram line like this:

convert -stroke red -fill none -linewidth 2 -draw "polyline `tail -600 data.txt | awk 'BEGIN {szum=0} {szum=szum+$1} {if (int(NR/5)==NR/5) ix=ix+1} { if (int(NR/5)==NR/5) printf ix "," 100-int(szum/250000) " " } { if (int(NR/5)==NR/5) szum=0 }'`" diagram.gif diagram.gif

Additional diagram lines can be drawn by repeating the "line drawing" convert command using the new data.
Some text and scales can be drawn on the diagram by adding them (line and text primitives of the -draw command) to the first, "image creating" convert command.

Somewhere between 120 and 200 diagram points some internal limit of ImageMagick is reached, and it returns an error rather than drawing the diagram.

homey 11-10-2004 07:19 PM

I don't suppose we could see your data.txt also? :)

J_Szucs 11-11-2004 02:51 AM

My data txt is nothing special, it only contains some space-separated numbers in each line like this:
12454 23456
236543 4564564
...
4534534 453464

Some byte-counting rules are inserted among my ipfw firewall rules during boot up; and an other script of mine reads out the positions of the counters once in each minute; calculates the traffic (ActualCounterPosition - PrevCounterPosition) of the last minute and appends it to data.txt.
So, data.txt contains web traffic data in my case; and the diagrams show my webtraffic


All times are GMT -5. The time now is 10:41 AM.