 | |
08-05-2003, 06:51 AM
|
#1 (permalink)
| | Registered User
Join Date: Oct 2002 Location: Scotland, UK
Posts: 2,946
| » 
Converting Image files in a script
Right, for a project I am doing, I would like to be able to do the following:
Create a set of (about 40-50) tiles/icons each in seperate files, named in the format "xx.bmp" where xx is a number I assign the tile.
Run a script (I'm thinking ImageMagick could do this, but I'm not sure how to actually do it) that will render all these tiles to a single file, so that instead of having them all in seperate ones, I could have them all as one image, which is blitted from each time, rather than having lots of surfaces open.
What I mean by that is, say I had 100 tiles at 64x64 pixels, it would create an image 640x640 pixels big, and render ten of these tiles on a row, and another ten immediatly below, so that I could just set up a rectangle and blit from here.
__________________
_____
NuKeS
|
| |
08-05-2003, 08:13 AM
|
#2 (permalink)
| | Registered User
Join Date: Jun 2002 Location: Iowa
Posts: 2,527
|
I didn't fix the code..... but here is the method anyway  You should be able to set it up using something like this. Quote:
#!/usr/bin/perl -w
# Example 3-2.
use strict;
use Image::Magick;
my $img = new Image::Magick;
# Read all of the images with a .gif
# extension in the current bdirectory
my $status = $img->Read("*.gif");
if ($status) {
die "$status";
}
# Montage() returns a new image
my $montage = $img->Montage(geometry =>'100x100',
tile =>'3x2',
borderwidth => 2);
$montage->Write('png:montage1.png');
# Also try:
# my $montage = $img->Montage(
# geometry=>'100x100',
# tile => '3x2',
# background => '#FFFFFF',
# pointsize => 12,
# label => "%f\n%wx%h\n(%b)",
# fill => '#000000',
# borderwidth => 2
#);
#my $montage = $img->Montage(
# geometry => "100x100+10+10",
# tile => '3x2',
# background => '#FFFFFF',
# label => "%f",
# mode => 'Frame',
# frame => "10x10+2+4"
#);
| Example script is from : http://shawn.apocabilly.org/PGP/examples/example3-2.txt
__________________
The day Microsoft makes something that doesn't suck is probably the day they start making vacuum cleaners. --- Author Unknown.
|
| |
08-05-2003, 08:22 AM
|
#3 (permalink)
| | Registered User
Join Date: Jun 2002 Location: Iowa
Posts: 2,527
|
See also: http://www.imagemagick.org/www/montage.html#exam
montage +frame +shadow +label -tile 5x1 -geometry 50x50+0+0 *.png joined.png
__________________
The day Microsoft makes something that doesn't suck is probably the day they start making vacuum cleaners. --- Author Unknown.
|
| |
08-05-2003, 08:47 AM
|
#4 (permalink)
| | Registered User
Join Date: Oct 2002 Location: Scotland, UK
Posts: 2,946
|
Thanks. I'm now trying to figure out what it all actually does. Looks like I'll have to do some reading for this too.
__________________
_____
NuKeS
|
| |
08-05-2003, 08:51 AM
|
#5 (permalink)
| | Registered User
Join Date: Feb 2003 Location: Da Bronx, NY
Posts: 1,709
|
when you get it working post the result, I'm real curious how it will look
|
| |
08-05-2003, 08:53 AM
|
#6 (permalink)
| | Registered User
Join Date: Oct 2002 Location: Scotland, UK
Posts: 2,946
|
Sorted. Cheers c.
__________________
_____
NuKeS
|
| |
08-05-2003, 09:06 AM
|
#7 (permalink)
| | Registered User
Join Date: Jun 2002 Location: Iowa
Posts: 2,527
|
I used the second method before....... works really well.
__________________
The day Microsoft makes something that doesn't suck is probably the day they start making vacuum cleaners. --- Author Unknown.
|
| |
08-05-2003, 09:40 AM
|
#8 (permalink)
| | Registered User
Join Date: Oct 2002 Location: Scotland, UK
Posts: 2,946
| http://www23.brinkster.com/nukes031/tiles.tar.gz
Thats the individual pics and set.jpg is the output.
I created it using: Code: montage +frame +label -tile 4x4 -geometry 64x64+0+0 *.bmp set.jpg
__________________
_____
NuKeS
|
| |
08-05-2003, 09:41 AM
|
#9 (permalink)
| | Registered User
Join Date: Oct 2002 Location: Scotland, UK
Posts: 2,946
|
I can just stick that into my makefile now, and save some hassle.
__________________
_____
NuKeS
|
| |
08-05-2003, 10:05 AM
|
#10 (permalink)
| | Registered User
Join Date: Jun 2002 Location: Iowa
Posts: 2,527
|
Image Magick is pretty cool isn't it
__________________
The day Microsoft makes something that doesn't suck is probably the day they start making vacuum cleaners. --- Author Unknown.
|
| | |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | | | | Thread Tools | | | | Display Modes | Linear Mode |
Posting Rules
| You may not post new threads You may not post replies You may not post attachments You may not edit your posts HTML code is Off | | | | Most Active Discussions  | | | | | Recent Discussions  | | | | | |