convert graphic file to x,y coordinates

M

Mike Solomon

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
:)
 
J

John Bokma

Mike said:
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?
 
S

Sandman

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.
 
G

Gregory Toomey

Mike said:
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
 
S

Sherm Pendley

Mike said:
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--
 
J

Jürgen Exner

Mike said:
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
 
M

Mike Solomon

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,013
Latest member
KatriceSwa

Latest Threads

Top