Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > convert graphic file to x,y coordinates

Reply
Thread Tools

convert graphic file to x,y coordinates

 
 
Mike Solomon
Guest
Posts: n/a
 
      04-26-2004
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

 
Reply With Quote
 
 
 
 
John Bokma
Guest
Posts: n/a
 
      04-26-2004


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/
 
Reply With Quote
 
 
 
 
Sandman
Guest
Posts: n/a
 
      04-26-2004
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]
 
Reply With Quote
 
Gregory Toomey
Guest
Posts: n/a
 
      04-26-2004
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
 
Reply With Quote
 
Sherm Pendley
Guest
Posts: n/a
 
      04-26-2004
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
 
Reply With Quote
 
Jürgen Exner
Guest
Posts: n/a
 
      04-26-2004
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


 
Reply With Quote
 
Mike Solomon
Guest
Posts: n/a
 
      04-27-2004
(Mike Solomon) wrote in message news:<. com>...
> 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
 
Reply With Quote
 
 
 
Reply

Thread Tools

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
how to convert array or coordinates to image Eadmund@letterbee.com Javascript 3 12-29-2006 06:55 PM
Is it possible to mouseover a GRAPHIC . . . that launches another (freestanding) GRAPHIC (ie. when flash is _not_ available)? 50 SOMETHING GAL HTML 3 12-10-2006 01:10 AM
Convert coordinates XY into LAT-LONG steeve.nadeau@mobilair.qc.ca Perl 1 11-04-2003 08:20 PM
Converting canvas coordinates to window coordinates in tkinter......... Suresh Kumar Python 0 07-04-2003 10:14 AM
Converting canvas coordinates to window coordinates....... Suresh Kumar Python 0 07-03-2003 04:53 AM



Advertisments