combining graphs from GD::Graph in one image file

Ask a Question related to PERL Modules, Design and Development.

  1. #1

    Default combining graphs from GD::Graph in one image file

    Does anybody know how I can get more than one graph on a single image
    file generated by the GD:Graph module?

    I need to generate a lot of histograms which cannot be combined into a
    single chart but all of these charts should be combined into one big
    image file (doesn't need to be pretty). I need to make a lot of these
    so combining the images by hand would not be ideal - is there a way to
    do this in GD:Graph?

    Thanks a lot!

    tospo Guest

  2. Similar Questions and Discussions

    1. #39893 [NEW]: Image/Graph/Plot/Odo.php syntax error
      From: dvboom at hotmail dot com Operating system: windowsxp PHP version: 4.4.4 PHP Bug Type: *General Issues Bug...
    2. GD::Graph - how to get rid of leading gap in line graph?
      Is there a way to get rid of the leading gap to the left of a line graph? Therefore, I want the graph line to start on the Y-axis, not the...
    3. Need to convert a SWF Chart/Graph to Image file.
      I've already tried the Flash forum, but I haven't gotten that much luck. On the off chance that there's a non-flash solution to my problem, I'm...
    4. Combining separate .pdf pages into one file
      I am using Win XP Professional. Can .pdf pages be combined into one file using Adobe Acrobat Reader? If not, which free version of Adobe Acrobat will...
    5. Optimizing / combining a sliced up vector file for vinyl cutting
      I am a novice Illustrator user in need of getting some banners made. I used Illustrator CS to modify a Clip-Art file that I had. The image was saved...
  3. #2

    Default Re: combining graphs from GD::Graph in one image file

    tospo schreef:
    > Does anybody know how I can get more than one graph on a single image
    > file generated by the GD:Graph module?
    Is that a real question? I don't think so. Please read
    [url]http://www.catb.org/~esr/faqs/smart-questions.html[/url]

    > I need to generate a lot of histograms which cannot be combined into a
    > single chart
    Why not?

    > but all of these charts should be combined into one big
    > image file (doesn't need to be pretty).
    What is your definition of 'combined'? For 'not pretty' you could put
    them all transparently on top of each other.

    > I need to make a lot of these
    > so combining the images by hand would not be ideal - is there a way to
    > do this in GD:Graph?
    I think you mean GD::Graph. I would use the module GD to do this.

    --
    Affijn, Ruud

    "Gewoon is een tijger."


    Dr.Ruud Guest

  4. #3

    Default Re: combining graphs from GD::Graph in one image file

    Apologies if this was unclear and sorry for the typo.

    I cannot combine all of my histograms for one dataset into one chart
    because there will be dozens of them and the output will not be
    readable.

    By "not pretty" I meant that it doesn't have to be formatted for
    printing or anything. It is fine if this generates a big image that one
    needs to scroll through on a computer screen because that's all that I
    want to do with it.

    So what I want the output of my script to look like is this:

    chart 1 chart 2
    | |
    +------ +---------

    chart 3 chart 4
    | |
    +------ +----------

    I couldn't find anything on the internet that shows me how (and if)
    this can be done in GD::Graph.

    How would I do this with GD?

    Thank you very much for your help,

    tospo

    tospo Guest

  5. #4

    Default Re: combining graphs from GD::Graph in one image file

    On Mon, 29 May 2006 05:15:25 -0700, tospo wrote:
    > By "not pretty" I meant that it doesn't have to be formatted for
    > printing or anything. It is fine if this generates a big image that one
    > needs to scroll through on a computer screen because that's all that I
    > want to do with it.
    [url]http://www.imagemagick.org/script/perl-magick.php#montage[/url]

    --
    Peter Scott
    [url]http://www.perlmedic.com/[/url]
    [url]http://www.perldebugged.com/[/url]

    Peter Scott Guest

  6. #5

    Default Re: combining graphs from GD::Graph in one image file

    tospo wrote:
    > Apologies if this was unclear and sorry for the typo.
    >
    > I cannot combine all of my histograms for one dataset into one chart
    > because there will be dozens of them and the output will not be
    > readable.
    >
    > By "not pretty" I meant that it doesn't have to be formatted for
    > printing or anything. It is fine if this generates a big image that one
    > needs to scroll through on a computer screen because that's all that I
    > want to do with it.
    >
    > So what I want the output of my script to look like is this:
    >
    > chart 1 chart 2
    > | |
    > +------ +---------
    >
    > chart 3 chart 4
    > | |
    > +------ +----------
    >
    > I couldn't find anything on the internet that shows me how (and if)
    > this can be done in GD::Graph.
    >
    > How would I do this with GD?
    >
    I think the terms you're (collectively) searching for are
    "composite" vs. "tiled", ie, composite mashes all the
    charts into a single set of axes; tiled is what is described above.

    That said, AFAIK, GD::Graph doesn't directly support tiling;
    however, implementing it directly in GD should be pretty
    straightforward.

    1. Create each chart as a standalone image.

    2. Compute the size needed to contain the charts as tiles

    3. Create a new GD::Image

    4. Copy each chart image into the tiled image at the proper
    coordinates

    E.g., if all are same size, then (psuedocode):

    #
    # create charts here as usual, pushing each resulting
    # GD::Image object on @charts
    #
    $Htiled = $Hchart * 2 + $vmargin; # height + some vertical margin
    $Wtiled = $Wchart * 2 + $hmargin; # width + some horiz. margin

    my $tiled = new GD::Image($Wtiled, $Htiled);
    my $white = $tiled->colorAllocate(255, 255, 255);
    #
    # fill the background
    #
    $tiled->filledRectangle(0,0,$Wtiled-1, $Htiled-1, $white);
    #
    # compute coords of each tiled chart
    # NOTE: these need adjustment for the margin spacing
    #
    my @coords = (
    0, 0,
    $Wtiled/2, 0,
    0, $Htiled/2,
    $Wtiled/2, $Htiled/2
    );

    $tiled->copy($_, shift @corrds, shift @coords, 0,0,$Wchart,$Hchart)
    foreach (@charts);

    open TILED, ">$tiled_file";
    binmode TILED;
    print TILED $tiled->png();
    close TILED;


    HTH,
    Dean Arnold
    Presicient Corp.
    Dean Arnold Guest

  7. #6

    Default Re: combining graphs from GD::Graph in one image file

    Thank you all very much!!!! I guess that gives me enough to try out for
    the time being.

    tospo

    tospo Guest

  8. #7

    Default Re: combining graphs from GD::Graph in one image file

    On Mon, 29 May 2006 22:15:25 +1000, tospo wrote:

    Hi tospo


    CPAN is your friend. Search for chart. Eg:

    [url]http://search.cpan.org/~rsavage/Image-Magick-Chart-1.02/[/url]


    Ron Savage Guest

  9. #8

    Default [ANNOUNCE] GD::Tiler (was Re: combining graphs from GD::Graph inone image file)

    tospo wrote:
    > Thank you all very much!!!! I guess that gives me enough to try out for
    > the time being.
    >
    > tospo
    >
    You got me itching, so I scratched. I've been
    meaning to add tiling support to DBIx::Chart anyway.

    I've just uploaded GD::Tiler to CPAN. It indexed OK, so it
    should be showing up in a few hours.

    Its pretty simple, just one method, and
    you pass in an arryaref of GD::Image objects or image filenames,
    plus a few other configuration parameters, and it spits
    out a new GD::Image object with the input tiled (and, in array context,
    also returns the coordinates of individual images in the tiled
    output).

    Regards,
    Dean Arnold
    Presicient Corp.
    Dean Arnold Guest

  10. #9

    Default Re: GD::Tiler (was Re: combining graphs from GD::Graph in one image file)


    Dean Arnold wrote:
    > tospo wrote:
    > > Thank you all very much!!!! I guess that gives me enough to try out for
    > > the time being.
    > >
    > > tospo
    > >
    >
    > You got me itching, so I scratched. I've been
    > meaning to add tiling support to DBIx::Chart anyway.
    >
    > I've just uploaded GD::Tiler to CPAN. It indexed OK, so it
    > should be showing up in a few hours.
    >
    > Its pretty simple, just one method, and
    > you pass in an arryaref of GD::Image objects or image filenames,
    > plus a few other configuration parameters, and it spits
    > out a new GD::Image object with the input tiled (and, in array context,
    > also returns the coordinates of individual images in the tiled
    > output).
    >
    > Regards,
    > Dean Arnold
    > Presicient Corp.
    Thanks Dean, this module is exactly what I needed. Works fine for me.
    Just a suggestions: would it be possible to add another argument for
    the maximum number of images in a row? Could help to make the output
    more printer-friendly.

    tospo Guest

  11. #10

    Default Re: GD::Tiler (was Re: combining graphs from GD::Graph in one imagefile)

    tospo wrote:
    > Dean Arnold wrote:
    >>
    >> I've just uploaded GD::Tiler to CPAN. It indexed OK, so it
    >> should be showing up in a few hours.
    >>
    >> Its pretty simple, just one method, and
    >> you pass in an arryaref of GD::Image objects or image filenames,
    >> plus a few other configuration parameters, and it spits
    >> out a new GD::Image object with the input tiled (and, in array context,
    >> also returns the coordinates of individual images in the tiled
    >> output).
    >>
    >> Regards,
    >> Dean Arnold
    >> Presicient Corp.
    >
    > Thanks Dean, this module is exactly what I needed. Works fine for me.
    > Just a suggestions: would it be possible to add another argument for
    > the maximum number of images in a row? Could help to make the output
    > more printer-friendly.
    >
    Not certain what you're issue is ? Since you have the ability
    to specify Width and Height, you should get the
    images positioned to fit your printer. Is the issue that
    you have too many images to fit within a specified Width/Height ?
    If so, I spose I could apply a scaling to the final image
    after tiling, along with a ImagesPerRow parameter. However,
    image quality would probably suffer (depending on how much
    scaling was needed).

    - Dean
    Dean Arnold Guest

  12. #11

    Default Re: GD::Tiler (was Re: combining graphs from GD::Graph in one imagefile)

    Dean Arnold wrote:
    > tospo wrote:
    >> Dean Arnold wrote:
    > >>
    >>> I've just uploaded GD::Tiler to CPAN. It indexed OK, so it
    >>> should be showing up in a few hours.
    >>>
    >>> Its pretty simple, just one method, and
    >>> you pass in an arryaref of GD::Image objects or image filenames,
    >>> plus a few other configuration parameters, and it spits
    >>> out a new GD::Image object with the input tiled (and, in array context,
    >>> also returns the coordinates of individual images in the tiled
    >>> output).
    >>>
    >>> Regards,
    >>> Dean Arnold
    >>> Presicient Corp.
    >>
    >> Thanks Dean, this module is exactly what I needed. Works fine for me.
    >> Just a suggestions: would it be possible to add another argument for
    >> the maximum number of images in a row? Could help to make the output
    >> more printer-friendly.
    >>
    >
    > Not certain what you're issue is ? Since you have the ability
    > to specify Width and Height, you should get the
    > images positioned to fit your printer. Is the issue that
    > you have too many images to fit within a specified Width/Height ?
    > If so, I spose I could apply a scaling to the final image
    > after tiling, along with a ImagesPerRow parameter. However,
    > image quality would probably suffer (depending on how much
    > scaling was needed).
    >
    > - Dean
    Oops, I think I understand your issue now. By specifying an
    ImagesPerRow, the default layout won't be "square",
    but could be thinner/taller (or wider/shorter)
    wo/ any scaling, and you don't need to specify any
    explicit Width/Height values.

    I'll see what I can do; I've also got some POD fixes
    to apply.

    - Dean
    Dean Arnold Guest

  13. #12

    Default Re: GD::Tiler (was Re: combining graphs from GD::Graph in one image file)

    > Oops, I think I understand your issue now. By specifying an
    > ImagesPerRow, the default layout won't be "square",
    > but could be thinner/taller (or wider/shorter)
    > wo/ any scaling, and you don't need to specify any
    > explicit Width/Height values.
    That's exactly what I meant. Of course you could always calculate the
    positions of your images to make them fit but what I like about your
    module is that I don't need to do that and I don't even need to know
    how many images I have.
    Thanks for your efforts!

    tospo

    tospo Guest

  14. #13

    Default Re: GD::Tiler (was Re: combining graphs from GD::Graph in one imagefile)

    tospo wrote:
    >> Oops, I think I understand your issue now. By specifying an
    >> ImagesPerRow, the default layout won't be "square",
    >> but could be thinner/taller (or wider/shorter)
    >> wo/ any scaling, and you don't need to specify any
    >> explicit Width/Height values.
    >
    > That's exactly what I meant. Of course you could always calculate the
    > positions of your images to make them fit but what I like about your
    > module is that I don't need to do that and I don't even need to know
    > how many images I have.
    > Thanks for your efforts!
    >
    > tospo
    >
    Done. GD-Tiler 0.11 uploaded, and CPAN has indexed it, but
    it'll probably take a few hours to be accessible.

    - Dean
    Dean Arnold Guest

  15. #14

    Default Re: GD::Tiler (was Re: combining graphs from GD::Graph in one image file)

    >
    > Done. GD-Tiler 0.11 uploaded, and CPAN has indexed it, but
    > it'll probably take a few hours to be accessible.
    >
    > - Dean
    I just tested it - excellent, thanks a lot!

    tospo

    tospo Guest

  16. #15

    Default combining graphs from GD::Graph in one image file

    A novice question. How do I export the image to a file. Using GD to
    binmode STDOUT; print $img->png;
    does not seem to work.
    Thanks,
    angshuman
    aguin Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139