NoobHelp overlay image with csv data

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
DeceiverZ
Posts: 5
Joined: 2014-02-28T14:36:37-07:00
Authentication code: 6789

NoobHelp overlay image with csv data

Post by DeceiverZ »

First post and I hope someone can provide useful information for how I can get started. I'm new to programming and am attempting to write my first script with imagemagick but am somewhat lost.

I have image files in a folder with each file using a naming convention which utilizes the date and time the image was taken:
YYYYMMDD-HourRMinuteSeconds.jpg
"20140227-134726.jpg" -Taken Feb 27 2014 at 01:47:26 PM

I also have several .csv files which contain data I wish to overlay onto all the images I have taken.

For example, "Humidity.csv" contains:
STAMP,VALUE
2014-02-27 13:36:41.312,45.3
2014-02-27 13:39:11.908,44.5
2014-02-27 13:41:42.07,43.7
2014-02-27 13:44:12.379,43.2
2014-02-27 13:46:42.489,43.1
2014-02-27 13:49:12.653,43.6
2014-02-27 13:51:43.197,44.2

"Temperature.csv" contains:
STAMP,VALUE
2014-02-27 14:44:27.952,22.4
2014-02-27 14:46:58.964,22.7
2014-02-27 14:49:29.863,23.1
2014-02-27 14:52:00.952,23.5
2014-02-27 14:54:31.916,23.8
2014-02-27 14:57:02.14,24.0
2014-02-27 14:59:32.304,24.1

Anybody have any clue how I could import the data from the CSV files, match the image timestamp to the closest timestamp of the CSV file, then overlay the corresponding temperature and humidity values onto an image?
I know it sounds easy, but for a non-programmer, it isn't. ANY help would be appreciated.

-DZ
Last edited by DeceiverZ on 2014-02-28T15:43:19-07:00, edited 1 time in total.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: NoobHelp overlay image with csv data

Post by snibgo »

I would do it with a simple database system that understands date/times.

The question doesn't seem at all specific to ImageMagick. It is specific to the script language / operating system you use. Whatever that is.
snibgo's IM pages: im.snibgo.com
DeceiverZ
Posts: 5
Joined: 2014-02-28T14:36:37-07:00
Authentication code: 6789

Re: NoobHelp overlay image with csv data

Post by DeceiverZ »

A simple database system would do the trick? I would love to hear some suggestions for tools to accomplish this if you have any..

I figured there would be some functions within ImageMagick that could facilitate these operations. Given that I'm working with CSV files, I figured it wouldn't be terribly difficult.

-DZ
Last edited by DeceiverZ on 2014-02-28T15:42:59-07:00, edited 1 time in total.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: NoobHelp overlay image with csv data

Post by fmw42 »

My understanding is that Imagemagick is mostly a raster image processing system. Its abilities to handle vector format data are much less sophisticated. It can overlay a SVG file onto an image. But it knows little about what information is in the vector file in a way that you could do any filtering. It just rasterizes it and then overlays it. In fact, IM relies upon delegates RSVG or Inkscape to deal with svg in a more flexible way that it own primitive MSVG.
DeceiverZ
Posts: 5
Joined: 2014-02-28T14:36:37-07:00
Authentication code: 6789

Re: NoobHelp overlay image with csv data

Post by DeceiverZ »

fmw42 wrote:My understanding is that Imagemagick is mostly a raster image processing system. Its abilities to handle vector format data are much less sophisticated. It can overlay a SVG file onto an image. But it knows little about what information is in the vector file in a way that you could do any filtering. It just rasterizes it and then overlays it. In fact, IM relies upon delegates RSVG or Inkscape to deal with svg in a more flexible way that it own primitive MSVG.
Thanks for the reply. Do you have any tools you could suggest for me?

I'm sure a simple script written in Python or Perl utilizing IM processing could accomplish the task I seek. However, I don't have much programming experience and would love it if someone could provide me with assistance.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: NoobHelp overlay image with csv data

Post by snibgo »

You have a list of filenames representing date/times. For each one, you want to find the nearest entry in each of two CSV files. This is a simple database style data-processing operation. But ImageMagick can't do it. It won't search through CSV files looking for the closest date/time match.
snibgo's IM pages: im.snibgo.com
DeceiverZ
Posts: 5
Joined: 2014-02-28T14:36:37-07:00
Authentication code: 6789

Re: NoobHelp overlay image with csv data

Post by DeceiverZ »

snibgo wrote:You have a list of filenames representing date/times. For each one, you want to find the nearest entry in each of two CSV files. This is a simple database style data-processing operation. But ImageMagick can't do it. It won't search through CSV files looking for the closest date/time match.
Right. I understand that ImageMagick is limited for such a "matching" operation. I agree that a database tool would be much better suited for that purpose. Python or Perl is what I would assume someone would turn to for help at this point.

I assume I would need a script that would:

1. Find all .jpg image files from a specified folder
2. Use the date and time values of that .jpg image file to find the closest timestamp value in the specified CSV
For image name "20140227-134726.jpg" -Taken Feb 27 2014 at 01:47:26 PM
The script would find:
(Humidity.csv -file)
STAMP,VALUE
2014-02-27 13:36:41.312,45.3
2014-02-27 13:39:11.908,44.5
2014-02-27 13:41:42.07,43.7
2014-02-27 13:44:12.379,43.2
2014-02-27 13:46:42.489,43.1
2014-02-27 13:49:12.653,43.6
2014-02-27 13:51:43.197,44.2

3. Overlay that value onto the .jpg image for example, "Humidity 43.1%" and then save the image with the overlay.

If anyone has the programming know-how to accomplish this, I would be very interested in speaking to you. I can tip in BTC/LTC and would immensely appreciate it.

-DZ
Last edited by DeceiverZ on 2014-02-28T16:18:21-07:00, edited 1 time in total.
vdch
Posts: 1
Joined: 2015-10-26T10:55:01-07:00
Authentication code: 1151

Re: NoobHelp overlay image with csv data

Post by vdch »

Hi

Did you finally manage to do it? I am trying to accomplish a similar task, any help on how achieve this would be more than welcome (using Python or any other scripting language)
Post Reply