LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices

Reply
 
Search this Thread
Old 04-22-2004, 07:26 PM   #1
J_Szucs
Senior Member
 
Registered: Nov 2001
Location: Budapest, Hungary
Distribution: SuSE 6.4-11.3, Dsl linux, FreeBSD 4.3-6.2, Mandrake 8.2, Redhat, UHU, Debian Etch
Posts: 1,126

Rep: Reputation: 58
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.
 
Old 04-23-2004, 06:20 AM   #2
J_Szucs
Senior Member
 
Registered: Nov 2001
Location: Budapest, Hungary
Distribution: SuSE 6.4-11.3, Dsl linux, FreeBSD 4.3-6.2, Mandrake 8.2, Redhat, UHU, Debian Etch
Posts: 1,126

Original Poster
Rep: Reputation: 58
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
 
Old 04-23-2004, 06:25 AM   #3
cmfarley19
Member
 
Registered: Nov 2002
Location: Central VA
Distribution: Ubuntu/Debian
Posts: 228

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

It sounds intriuging.
 
Old 11-10-2004, 06:57 PM   #4
J_Szucs
Senior Member
 
Registered: Nov 2001
Location: Budapest, Hungary
Distribution: SuSE 6.4-11.3, Dsl linux, FreeBSD 4.3-6.2, Mandrake 8.2, Redhat, UHU, Debian Etch
Posts: 1,126

Original Poster
Rep: Reputation: 58
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.

Last edited by J_Szucs; 11-11-2004 at 03:54 AM.
 
Old 11-10-2004, 08:19 PM   #5
homey
Senior Member
 
Registered: Oct 2003
Posts: 3,057

Rep: Reputation: 56
I don't suppose we could see your data.txt also?
 
Old 11-11-2004, 03:51 AM   #6
J_Szucs
Senior Member
 
Registered: Nov 2001
Location: Budapest, Hungary
Distribution: SuSE 6.4-11.3, Dsl linux, FreeBSD 4.3-6.2, Mandrake 8.2, Redhat, UHU, Debian Etch
Posts: 1,126

Original Poster
Rep: Reputation: 58
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

Last edited by J_Szucs; 11-11-2004 at 03:52 AM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
CVS Command Line tool not installed? TehFlyingDutchman Linux - Newbie 4 11-20-2005 07:51 PM
DHCP command line tool cold Fedora 1 11-09-2005 11:14 AM
Command line tool like fetchyahoo to fetch gmail? SharpyWarpy Linux - Software 2 09-07-2004 05:39 PM
command line tool to control volume? infected Programming 4 09-02-2004 09:58 AM
viewing images on the command line darkangel Linux - General 3 02-14-2002 11:44 AM


All times are GMT -5. The time now is 07:21 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration