convert graphic file to x,y coordinates

Discussion in 'Perl Misc' started by Mike Solomon, Apr 26, 2004.

  1. Mike Solomon

    Mike Solomon Guest

    I need to take a graphics file and then get the xy coordinates from it
    and insert them into a database

    so far the best way I have come up with is to use paint to get the
    cordinates and manually record them in a spreadsheet

    Is there any way I can use perl to read the graphics file and get the
    co-ordinates

    I am probably being optimistic but doing it manually is driving me mad
    :)
    Mike Solomon, Apr 26, 2004
    #1
    1. Advertising

  2. Mike Solomon

    John Bokma Guest

    Mike Solomon wrote:

    > I need to take a graphics file and then get the xy coordinates from it
    > and insert them into a database
    >
    > so far the best way I have come up with is to use paint to get the
    > cordinates and manually record them in a spreadsheet
    >
    > Is there any way I can use perl to read the graphics file and get the
    > co-ordinates
    >
    > I am probably being optimistic but doing it manually is driving me mad
    > :)


    What kind of graphics file, and how are xy coordinates marked?

    --
    John MexIT: http://johnbokma.com/mexit/
    personal page: http://johnbokma.com/
    Experienced Perl programmer available: http://castleamber.com/
    John Bokma, Apr 26, 2004
    #2
    1. Advertising

  3. Mike Solomon

    Sandman Guest

    In article <>,
    (Mike Solomon) wrote:

    > I need to take a graphics file and then get the xy coordinates from it
    > and insert them into a database
    >
    > so far the best way I have come up with is to use paint to get the
    > cordinates and manually record them in a spreadsheet
    >
    > Is there any way I can use perl to read the graphics file and get the
    > co-ordinates
    >
    > I am probably being optimistic but doing it manually is driving me mad
    > :)


    Try ImageMagick.

    ~> identify -verbose 1.jpg |grep Geometry
    Geometry: 1600x1200

    Use perl to parse the " Geometry: 1600x1200" line.

    There is also a ImageMagick library for perl, but I haven't used it.

    --
    Sandman[.net]
    Sandman, Apr 26, 2004
    #3
  4. Mike Solomon wrote:

    > I need to take a graphics file and then get the xy coordinates from it
    > and insert them into a database
    >
    > so far the best way I have come up with is to use paint to get the
    > cordinates and manually record them in a spreadsheet
    >
    > Is there any way I can use perl to read the graphics file and get the
    > co-ordinates
    >
    > I am probably being optimistic but doing it manually is driving me mad
    > :)


    Have a look at http://search.cpan.org/~lds/GD-2.12/GD.pm

    Try reading in an image:

    $image = GD::Image->newFromJpegData($data, [$truecolor])
    $image = GD::Image->newFromPng($file, [$truecolor])
    (there may be an earlier GD version that works wiht gifs)

    then get the pixels
    $image->getPixel(x,y)


    Buy why dont you insert the whole image into the database as a binary
    object?

    gtomey
    Gregory Toomey, Apr 26, 2004
    #4
  5. Mike Solomon wrote:

    > I need to take a graphics file and then get the xy coordinates from it
    > and insert them into a database


    What do you mean by "xy coordinates" - the size of the image?

    If so, why didn't you try searching for "image size" on CPAN? Doing so would
    have shown you the Image::Size module. It can read data from a file name,
    an in-memory buffer, or an open file handle, and supports most common image
    formats.

    sherm--

    --
    Cocoa programming in Perl: http://camelbones.sourceforge.net
    Hire me! My resume: http://www.dot-app.org
    Sherm Pendley, Apr 26, 2004
    #5
  6. Mike Solomon wrote:
    > I need to take a graphics file and then get the xy coordinates from it
    > and insert them into a database


    What kind of graphics file are you talking about? Vector graphic? Bitmap?
    BMP? JPEG? GIF? PNG? Or any other of the hundreds of lesser known formats?

    For some of them you should be able to find a parser on CPAN.
    If it is a vector graphic format then it should be easy to get to the xy
    coordinates of whatever objects you are after in your graphic (you didn't
    tell us, either).
    However, if you are after the xy-coordinates of objects in bitmap graphics,
    then the last time I checked that was still a very active research area and
    requires quite complex picture analysis and a lot of good guesses by the
    program. I doubt that there is anything on CPAN (although you never know)
    and actually Perl might not be the best tool for this kind of highly
    numerical analysis.

    jue
    Jürgen Exner, Apr 26, 2004
    #6
  7. Mike Solomon

    Mike Solomon Guest

    (Mike Solomon) wrote in message news:<>...
    > I need to take a graphics file and then get the xy coordinates from it
    > and insert them into a database
    >
    > so far the best way I have come up with is to use paint to get the
    > cordinates and manually record them in a spreadsheet
    >
    > Is there any way I can use perl to read the graphics file and get the
    > co-ordinates
    >
    > I am probably being optimistic but doing it manually is driving me mad
    > :)


    Thanks for the replies

    The files are either be jpeg or png

    I will try image magic and keep my fingers crossed

    The image is a stand map - basically black outlined rectangles on a
    white background

    I need to get the co-ordinates to pass them to a flash program and
    also so I can create a printable stand map

    I can't just store the image in the database as I need the
    co-ordinates
    Mike Solomon, Apr 27, 2004
    #7
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    1
    Views:
    21,305
    Jim Gibson
    Nov 4, 2003
  2. Suresh  Kumar
    Replies:
    0
    Views:
    577
    Suresh Kumar
    Jul 3, 2003
  3. Suresh  Kumar
    Replies:
    0
    Views:
    506
    Suresh Kumar
    Jul 4, 2003
  4. 50 SOMETHING GAL
    Replies:
    3
    Views:
    390
  5. Replies:
    3
    Views:
    152
    Dr J R Stockton
    Dec 29, 2006
Loading...

Share This Page