Assembling a .jpg image for lots of individual cells

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Prospero
Junior Coder
Posts: 20
Joined: Tue Jun 14, 2005 1:18 am

Assembling a .jpg image for lots of individual cells

Post by Prospero » Wed Jun 15, 2005 7:32 pm

Hi all,

I'd really appreciate some help with this problem:

I have 40,000 individual .jpg images - each of which is exactly 250 by 250 pixels and about 18KB - that I need to assemble and then display on screen as one continuous image. They need to be assembled and displayed in a square, 200 images by 200 images. They are named starting from 1.jpg (bottom left corner of the square) to 40000.jpg (top right corner of the square).

Here's a visualization of the layout:


39801,39802,39803,39804,39805,39806,39807... (up to 40000)
.........
................
.........................
...................................
1201,1202,1203,1204,1205,1206,1207... etc
1001,1002,1003,1004,1005,1006,1007... etc
801,802,803,804,805,806,807... etc
601,602,603,604,605,606,607... etc
401,402,403,404,405,406,407... (up to 600)
201,202,203,204,205,206,207... (up to 400)
1,2,3,4,5,6,7... (up to 200)


I've tried to do it by assembling the individual .jpg's (i.e. "tiles" or "cells") in a Dialog box using Image controls - which works in principle. But I can't set up a loop to read in the data within the Dialog function.

Doing this longhand, which as you can appreciate is moronic, would take 40,000 lines of code. I'm stuck!

Oh, and I need to be able to save the resulting (rather large) assembled .jpg.

Please help!

Prospero
Last edited by Prospero on Thu Jun 16, 2005 3:42 am, edited 1 time in total.

Me_again
Automation Wizard
Posts: 1101
Joined: Fri Jan 07, 2005 5:55 pm
Location: Somewhere else on the planet

Post by Me_again » Thu Jun 16, 2005 3:31 am

If nobody has a 100% macro scheduler solution I suggest you try ImageMagick http://www.imagemagick.org/script/index.php in command line mode which can easily be automated by macro scheduler.

This article http://software.newsforge.com/article.p ... 20&tid=131 shows the basic procedure for creating a mosaic. You can use loops in macro scheduler to generate the xy positions and filenames.

Prospero
Junior Coder
Posts: 20
Joined: Tue Jun 14, 2005 1:18 am

Post by Prospero » Thu Jun 16, 2005 10:03 am

Many thanks for your help. I have downloaded ImageMagick, and I'm sure it will be suitable for the task. My one question is how I make Macro Scheduler run a DOS-style command line. Could you give me a simple example?

(New to this).

Prospero
Last edited by Prospero on Thu Jun 16, 2005 3:06 pm, edited 1 time in total.

User avatar
support
Automation Wizard
Posts: 1450
Joined: Sat Oct 19, 2002 4:38 pm
Location: London
Contact:

Post by support » Thu Jun 16, 2005 10:12 am

To run any application or DOS command just use the Run Program command. If running a DOS command line it is usually sensible to first set RP_WAIT to 1 so that the script waits for the command to finish before continuing:

Let>RP_WAIT=1
Run>"c:\program files\some dir\someprog.exe" /parm1=value1 etc

If the command line or parameters have spaces in them put quotes around them.
MJT Net Support
[email protected]

Prospero
Junior Coder
Posts: 20
Joined: Tue Jun 14, 2005 1:18 am

Post by Prospero » Thu Jun 16, 2005 2:58 pm

Hi,

Golly, I need a little more help.

Let's say the DOS command line I want to execute is this:

c:\program files\imagemagick-6.2.3-Q16\convert.exe -size 5000x5000 xc:wheat multiple.jpg

(This will run one of the ImageMagick programs - namely, convert.exe).

What would be the correct Run> command? How to deal with the syntax of the parameters I'm passing to the executable confuses me...

Sorry to be such a fool!

Prospero

(I edited this just as you provided a reply! Hehe. Hence the altered path)
Last edited by Prospero on Fri Jun 17, 2005 12:19 am, edited 3 times in total.

User avatar
support
Automation Wizard
Posts: 1450
Joined: Sat Oct 19, 2002 4:38 pm
Location: London
Contact:

Post by support » Thu Jun 16, 2005 3:08 pm

Should just be:

Let>RP_WAIT=1
Run>c:\convert.exe -size 5000x5000 xc:wheat multiple.jpg

Is that wheat multiple.jpg one parameter? If so you may need:

Run>c:\convert.exe "-size 5000x5000" "xc:wheat multiple.jpg"

Try 'em and see.
MJT Net Support
[email protected]

Me_again
Automation Wizard
Posts: 1101
Joined: Fri Jan 07, 2005 5:55 pm
Location: Somewhere else on the planet

Post by Me_again » Thu Jun 16, 2005 4:21 pm

You can pass parameters from your macro by including them in the command with % signs around them. I'll post some macro scheduler/imagemagick examples later.

Prospero
Junior Coder
Posts: 20
Joined: Tue Jun 14, 2005 1:18 am

Post by Prospero » Thu Jun 16, 2005 7:41 pm

I look forward to seeing the examples.

Thanks!

Prospero

(and thankyou to MJT too)

Me_again
Automation Wizard
Posts: 1101
Joined: Fri Jan 07, 2005 5:55 pm
Location: Somewhere else on the planet

Post by Me_again » Fri Jun 17, 2005 2:55 am

This does a simple version of what you want, it creates 4 200x200 colored tiles and places them onto to a 200x800 base image. The filename for the tile and the x position are created/calculated in the macro and passed as parameters to the imagemagick command. Note that my imagemagick is in c:\imag, you should change to suit your paths. If you copy and paste this off the forum remember to remove trailing spaces.

Code: Select all

Let>RP_Wait=1
'Create the background image
Run>c:\imag\convert.exe -size 800x200 xc:wheat c:\imag\multiple.jpg
'Create 4 colored tiles
Run>c:\imag\convert.exe -size 200x200 xc:blue c:\imag\tile1.jpg
Run>c:\imag\convert.exe -size 200x200 xc:green c:\imag\tile2.jpg
Run>c:\imag\convert.exe -size 200x200 xc:red c:\imag\tile3.jpg
Run>c:\imag\convert.exe -size 200x200 xc:yellow c:\imag\tile4.jpg
'Initialize the tile filename variable
Let>tilenum=1
'Initialize the X position variable
Let>xpos=0
'Start the tiling
Label>loopit
'Create the full tile filename
Let>finame=tile
Concat>finame,%tilenum%
Concat>finame,.jpg
'Pass the filename and x position variables as imagemagick command line
Run>c:\imag\composite.exe -geometry +%xpos%+0 c:\imag\%finame% c:\imag\multiple.jpg c:\imag\multiple.jpg
'Increment the tile variable
Add>tilenum,1
'Increment the X position
Add>xpos,200
'See if we are there yet
If>tilenum>4,fin
'Return to the start of the loop to place the next tile
Goto>loopit
Label>fin
'That's all folks!
You can use very long command lines with imagemagick, here's one I use which adds weather conditions extracted from a datafile and time and date to a webcam image grabbed off the camera's server. (the variables are in there twice because the text is yellow with a black shadow and each color is written separately.

Code: Select all

run program>c:\imag\convert.exe c:\wdisplay\crop.jpg  -font Arial -pointsize 18 -draw "gravity south fill black  text 0,12 '%ttime% %ddate% %tlabel% %tamb% %hlabel% %hum% %wlabel% %wind% %rlabel% %rain%' fill yellow  text 1,11 '%ttime% %ddate% %tlabel% %tamb% %hlabel% %hum% %wlabel% %wind% %rlabel% %rain%' " c:\wdisplay\webfiles\imagem.jpg

Prospero
Junior Coder
Posts: 20
Joined: Tue Jun 14, 2005 1:18 am

Post by Prospero » Sat Jun 18, 2005 12:04 am

Thanks very much for that. I am in the process of getting it to work (will let you know). Superb and much appreciated.

By the way, you talk of weather conditions... but where do you get them from? (i.e. what is the website?).

Prospero

Me_again
Automation Wizard
Posts: 1101
Joined: Fri Jan 07, 2005 5:55 pm
Location: Somewhere else on the planet

Post by Me_again » Sat Jun 18, 2005 2:41 am

I started to think about the size of your final masterpiece and wonder if it will be a problem, for sure it's not going to be fast. I would try a small mosaic first, 20 by 20 or something and work up from that.

I have my own weather stations and use Weather-Display http://www.weather-display.com software to put the information on the web. Automating various add-ons to the setup is how I got started with Macro Scheduler. It's great software and I continue to find new uses for it all the time :D

Prospero
Junior Coder
Posts: 20
Joined: Tue Jun 14, 2005 1:18 am

Post by Prospero » Sun Jun 19, 2005 6:57 am

Hi,

Why is the assembly process so slow? It seems like some "image processing" is going on, when all I need is for the tiles to be assembled. Help!

Prospero

PS: Can I make a DOS program invisible when executed, rather than opening up in a window - so that it just works away in the "background" without troubling me?

User avatar
support
Automation Wizard
Posts: 1450
Joined: Sat Oct 19, 2002 4:38 pm
Location: London
Contact:

Post by support » Sun Jun 19, 2005 10:31 am

To make a DOS program invisible add the following line prior to the Run Program line:

Let>RP_WINDOWMODE=0

Assembling lots of images into one image will involve image processing as the software has to create a new image. For sure there will be a lot of image processing involved!
MJT Net Support
[email protected]

Me_again
Automation Wizard
Posts: 1101
Joined: Fri Jan 07, 2005 5:55 pm
Location: Somewhere else on the planet

Post by Me_again » Sun Jun 19, 2005 2:03 pm

I've never attempted such a big matrix, but there are several other ways to use imagick to make mosaics. Something like appending the images into horizontal or vertical strips and then appending those images might be faster. See here http://www.cit.gu.edu.au/~anthony/graph ... 6/mosaics/ for more ideas.

There's a great imagemagick forum at http://studio.imagemagick.org/magick/ where someone can surely tell you the best way to to do this.

Prospero
Junior Coder
Posts: 20
Joined: Tue Jun 14, 2005 1:18 am

Post by Prospero » Mon Jun 20, 2005 9:31 pm

support wrote:To make a DOS program invisible add the following line prior to the Run Program line:

Let>RP_WINDOWMODE=0

Assembling lots of images into one image will involve image processing as the software has to create a new image. For sure there will be a lot of image processing involved!

Hi,

I'm getting there - gradually;)

My latest question is do I only have to issue the Let>RP_WINDOWMODE=0 command once?

Prospero

Post Reply
cron
Sign up to our newsletter for free automation tips, tricks & discounts