View Full Version : OT: Automated resizing of images ?
Ragnarok-X
May 1st, 2008, 08:19 AM
I need to convert a load of 512x512 sized images into 128x128. Anyone knows about a automated method/tool to do so ?
narf poit chez BOOM
May 1st, 2008, 10:40 AM
Maybe Gimp?
Ed Kolis
May 1st, 2008, 12:11 PM
IrfanView can do that... hmm, converting SE5 portraits to SE4 size? http://forum.shrapnelgames.com/images/smilies/wink.gif
geoschmo
May 1st, 2008, 01:52 PM
Irfan view does a great job of it. I've got a script that runs on the PBW server using irfan view which resizes, crops, and changes the flag bitmaps to jpegs and sticks them in the image folder for the game page previews.
Ragnarok-X
May 1st, 2008, 02:41 PM
Yeah got. Its really good, you can as well rename the batch and or extensions or something. Thanks.
Fyron
May 1st, 2008, 02:55 PM
I prefer Python's PIL library myself. Less overhead, less hassle with Irfanview's bizarre interface and interpretation of settings.. This little script helps me prepare shipsets for posting in the SEnet shipyards. I didn't have to do any resizing, but you can find info on how to do that here (http://www.daniweb.com/code/snippet396.html).
(bloody code tag sucks... stupid extra line breaks)
<pre>
# http://www.pythonware.com/library/pil/handbook/image.htm
from PIL import Image
import sys
import os
import re
import shutil
shipset_path = sys.argv[1]
if len(sys.argv) > 2:
if sys.argv[2] == 'se4' or sys.argv[2] == '4':
game = 'se4'
else:
game = 'se5'
else:
game = 'se5'
files = os.listdir(shipset_path)
set_name = shipset_path.rstrip('_')
out_path = 'D:/Internet/SEnet/home/modules/Shipyards/images/races/' + game + \
'/' + set_name.lower() + '/'
try:
os.mkdir(out_path)
except WindowsError:
1
# Create an empty index.html file.
index_file = open(out_path + 'index.html', 'w')
index_file.close()
portrait_match = re.compile('_portrait_[a-z]+.bmp')
mini_match = re.compile('_mini_[a-z]+.bmp')
se4_specials = [set_name.lower() + '_pop_mini.bmp', set_name.lower() + \
'_pop_portrait.bmp', set_name.lower() + '_main.bmp', set_name.lower() + \
'_bigexplosion.bmp', set_name.lower() + '_shields.bmp']
for f_raw in files:
f = f_raw.lower()
if f == set_name.lower() + '_flag_texture.bmp' or f == set_name.lower() + \
'_race_portrait.bmp' or portrait_match.search(f) != None or \
(game == 'se4' and mini_match.search(f) != None or f in se4_specials):
im = Image.open(set_name + '/' + f)
im.save(out_path + f.replace('.bmp', '.png'), 'png')
# Create a preview image.
if game == 'se5':
shutil.copyfile(set_name + '/' + set_name + \
'_LargePortrait_Dreadnought.jpg', 'preview/' + set_name.lower() + '.jpg')
else:
im = Image.open(set_name + '/' + set_name + '_Portrait_Dreadnought.bmp')
im.save('preview/' + set_name.lower() + '.png', 'png')
</pre>
vBulletin® v3.8.1, Copyright ©2000-2025, Jelsoft Enterprises Ltd.