Jump to content


Photo

BAM Resizer

bamresize BAM

  • Please log in to reply
28 replies to this topic

#1 Sam.

Sam.
  • Administrator
  • 1335 posts

Posted 20 August 2014 - 07:03 PM

File Name: BAM Resizer
File Submitter: Sam.
File Submitted: 20 Aug 2014

File Updated: 06 Dec 2016
File Category: IE Modding Tools

Original quote from PPG's IE Modding Tools:

BAM Resizer
This nifty little tool was developed to try and facilitate the porting of PST avatars to BG2. The problem was that all the Planescape avatars were larger than those in Baldur's Gate 2 by a 4:3 ratio. The author's name is unknown, but we appreciate his efforts.


Usage:

bamresize v2.9
Code contributions by Avenger_teambg and Sam.

bamresize [OPTIONS] filename.bam [filename2.bam...]
Resizes all frames in filename.bam, creating a new file called filenamer.bam.
The filename(s) to convert can use wildcards.

Options:
 '-p PERCENT'
 '--percentw PERCENT'
    Frame widths are resized by PERCENT percent.
    Default is 75
 '-q PERCENT'
 '--percenth PERCENT'
    Frame heights are resized by PERCENT percent.
    Default is the value for -p (if specified), otherwise it is 75
 '-x NUMBER'
 '--modxoffset NUMBER'
    Modify (either increment or decrement) x offsets by NUMBER.
    Default is 0
 '-y NUMBER'
 '--modyoffset NUMBER'
    Modify (either increment or decrement) y offsets by NUMBER.
    Default is 0
 '-s NUMBER'
 '--setxoffset NUMBER'
    Set x offsets to NUMBER.
    Default is NONE
 '-v NUMBER'
 '--setyoffset NUMBER'
    Set y offsets to NUMBER.
    Default is NONE
 '-u VALUE'
 '--unify VALUE'
    Pad frames before resize to make dimensions and offsets uniform.
    This eliminates frame 'twitching' when resized.
    For VALUE, 0 is OFF, 1 is ON, and 2 is square.  Default is 1.
 '-t VALUE'
 '--trim VALUE'
    Trim transparent padding from frame after resize. (Opposite of --unify)
    For VALUE, 0 is OFF and 1 is ON.  Default is 1.
 '-e FORMAT'
 '--export FORMAT'
    Export frames in the basic format indicated by FORMAT.
    Examples include "bmp", "png", and "gif".  Default is do not export.
 '-h'
 '--help'
    Print this message.

Examples:
bamresize MNO3A1.bam
 Resizes all the frames in MNO3A1.bam by 75% and creates MNO3A1r.bam

bamresize -p 50 -q 150 c:\extractedBams\*.bam
 Resizes all frame widths by 50% and all frame heights by 150% for all .bam
 files in the \extractedBams dir.

bamresize -p 100 -s -10 -y 15 ABATG1.bam
 Sets all x offsets to -10 and increments all y offsets by 15 without resizing
 frames.

See <src\usage.txt> for extended usage and examples.

Changelog:

Version History:

v1.5 (17 February 2003)
     * Latest release on PPG

v2.1 (13 October 2013)
     * Implemented Avenger_teambg's end main() and resizeFrame() fixes from <http://forums.pocketplane.net/index.php/topic,28376.0.html>
     * Fixed a bug in compressFrame() that caused pixel row misalignment in BAM frames after resize under some circumstances.

v2.2 (11 January 2014)
     * Width and height resizing is decoupled to allow specifying separate values.  Use "-p" to scale width and "-q" to scale height. Whichever ones not specified will default to 75%.

v2.3 (19 January 2014)
     * Value of -q (height) now defaults to the -p (width) value (instead of 75%) if it is otherwise unspecified.

v2.4 (18 March 2015)
     * Fixed a bug in the frame offset calculations of negative numbers.
     * Added option to not recalculate (scale) frame offsets with resize. ['-n' or '--norecalcoffset']
     * Added option to modify (either increment or decrement) x and y offsets by a positive or negative number. ['-x NUMBER' or '--modxoffset NUMBER'] and ['-y NUMBER' or '--modyoffset NUMBER']
     * Added option to set x and y offsets to a positive or negative number.  ['-s NUMBER' or '--setxoffset NUMBER'] and ['-t NUMBER' or '--setyoffset NUMBER']
     * Compiled into self-contained EXE.

v2.5 (16 June 2015)
     * Added option to pad the frames (with transparent pixels) before resizing them to ensure the resized dimensions and offsets are uniform.  This eliminates frame 'twitching' when resized.  ['-u' or '--unify']
     * Added option to trim the padding (transparent pixels) from the frames after resizing them.  This is the opposite of --unify.  ['-t' or '--trim']
     * Removed option to not recalculate (scale) frame offsets with resize. ['-n' or '--norecalcoffset']
     * Modified the option to set the y offset to a positive or negative number to use ['-v NUMBER' or '--setyoffset NUMBER'] instead of ['-t NUMBER' or '--setyoffset NUMBER']

v2.6 (20 June 2015)
     * Improved handling of very small frame dimensions (<= 1 px).
     * Added undocumented ['-d' or '--debug'] option to print some debug information to console.

v2.7 (22 June 2015)
     * Updated Python to v2.1.3, updated PyWin32 to Build 151, and upgraded the Python Imaging Library to v1.1.5.
     * Included installers for the above plus PyInstaller for posterity.
     * Included the entire PIL with BAM Resizer.
     * Added option to export the frames as BMPs. ['-e' or '--export']
     * Fixed several bugs in how input Options were processed.
     * Unify and Trim options are now ON by default and require a second parameter when specified: ['-u VALUE' or '--unify VALUE'] and ['-t VALUE' or '--trim VALUE']
     * Unify can now pad the frames until they are square by setting the option's value to 2.  ['-u 2' or '--unify 2']

v2.8 (06 July 2015)
     * Fixed a bug in how unify was implemented when set to square.
     * Fixed a bug where frames were being exported before being resized, not after.
     * Fixed several more bugs in how input Options were processed, resulting in them being applied in a more logical order.
     * Added option to export frames in the basic format indicated by FORMAT:  ['-e FORMAT' or '--export FORMAT'] Examples include "bmp", "png", and "gif".  Default is do not export.
     * usage.txt documentation included.

v2.9 (06 December 2016)
     * Improved handling of corrupt RLE'd frame data.

 
Click here to download this file


Edited by Sam., 29 August 2022 - 08:27 AM.

"Ok, I've just about had my FILL of riddle asking, quest assigning, insult throwing, pun hurling, hostage taking, iron mongering, smart-arsed fools, freaks, and felons that continually test my will, mettle, strength, intelligence, and most of all, patience! If you've got a straight answer ANYWHERE in that bent little head of yours, I want to hear it pretty damn quick or I'm going to take a large blunt object roughly the size of Elminster AND his hat, and stuff it lengthwise into a crevice of your being so seldom seen that even the denizens of the nine hells themselves wouldn't touch it with a twenty-foot rusty halberd! Have I MADE myself perfectly CLEAR?!"

--<CHARNAME> to Portalbendarwinden

--------------------

post-10485-0-15080600-1348188745.jpg
___________Old pen and paper modules of the 70s and 80s.___________

CA Forums CA Homepage


#2 Daulmakan

Daulmakan

    Comfortably numb

  • Member
  • 1065 posts

Posted 24 August 2014 - 03:00 PM

I'm getting a 'unknown format or file is damaged' when trying to open it.


item_pack.jpg   Drows.jpg

 


#3 Sam.

Sam.
  • Administrator
  • 1335 posts

Posted 24 August 2014 - 04:06 PM

I'm getting a 'unknown format or file is damaged' when trying to open it.

The first thing that comes to mind is that it will only work with BAM V1 and BAMC V1 files (not the EE V2 files using the PVR(Z) format).  Wit that being said, BAM Resizer should have thrown an error saying the file "is not a BAM file" or that it "Can't handle file version:" bla.  Can you tell me exactly the syntax you used to run it, and send me the BAM file you tried it with?


"Ok, I've just about had my FILL of riddle asking, quest assigning, insult throwing, pun hurling, hostage taking, iron mongering, smart-arsed fools, freaks, and felons that continually test my will, mettle, strength, intelligence, and most of all, patience! If you've got a straight answer ANYWHERE in that bent little head of yours, I want to hear it pretty damn quick or I'm going to take a large blunt object roughly the size of Elminster AND his hat, and stuff it lengthwise into a crevice of your being so seldom seen that even the denizens of the nine hells themselves wouldn't touch it with a twenty-foot rusty halberd! Have I MADE myself perfectly CLEAR?!"

--<CHARNAME> to Portalbendarwinden

--------------------

post-10485-0-15080600-1348188745.jpg
___________Old pen and paper modules of the 70s and 80s.___________

CA Forums CA Homepage


#4 Daulmakan

Daulmakan

    Comfortably numb

  • Member
  • 1065 posts

Posted 24 August 2014 - 09:18 PM

Sorry, I should've been clearer. I can't even open the downloadable .rar in the first place. Using firefox or chrome seems to yield the same ¿corrupted? download.


item_pack.jpg   Drows.jpg

 


#5 Sam.

Sam.
  • Administrator
  • 1335 posts

Posted 25 August 2014 - 06:18 AM

Oh, just go get the latest version of WinRar. I guess browsers/OSs don't natively support the latest .RAR format (it was upgraded a year or so ago).

 

Edit:  You will need WinRAR Version 5.00 or newer.


Edited by Sam., 27 August 2014 - 09:45 PM.

"Ok, I've just about had my FILL of riddle asking, quest assigning, insult throwing, pun hurling, hostage taking, iron mongering, smart-arsed fools, freaks, and felons that continually test my will, mettle, strength, intelligence, and most of all, patience! If you've got a straight answer ANYWHERE in that bent little head of yours, I want to hear it pretty damn quick or I'm going to take a large blunt object roughly the size of Elminster AND his hat, and stuff it lengthwise into a crevice of your being so seldom seen that even the denizens of the nine hells themselves wouldn't touch it with a twenty-foot rusty halberd! Have I MADE myself perfectly CLEAR?!"

--<CHARNAME> to Portalbendarwinden

--------------------

post-10485-0-15080600-1348188745.jpg
___________Old pen and paper modules of the 70s and 80s.___________

CA Forums CA Homepage


#6 The Imp

The Imp

    Not good, see EVIL is better. You'll LIVE.

  • Member
  • 5155 posts

Posted 25 August 2014 - 06:58 AM

Oh, just go get the latest version of WinRar. I guess browsers/OSs don't natively support the latest .RAR format (it was upgraded a year or so ago).

So the WinRAR v4.01 couldn't extract it here either, but the v5.11 or whatever can.


Yep, Jarno Mikkola. my Mega Mod FAQ. Use of the BWS, and how to use it(scroll down that post a bit). 
OK, desert dweller, welcome to the sanity, you are free to search for the limit, it's out there, we drew it in the sand. Ouh, actually it was still snow then.. but anyways.


#7 Sam.

Sam.
  • Administrator
  • 1335 posts

Posted 20 October 2014 - 09:59 PM

I think I finally figured out how to compile the thing (with great effort and a limited number of compile options).  It should work, though.  If anyone cares to give it a try, please do and let me know if it blows up or does anything unexpected.  "bamresize.exe" should be completely self contained and portable, which is a plus.  On the downside, it takes a small amount of time for the EXE to unpack its internal files.  As a result, it will be slightly faster to run bamresize from the sourcecode (as in my previous versions) if bamresize is being opened and closed a large number of times (as in batch processing hundreds of individual files instead of running bamresize once using wildcards).

 

If a few people try it and report having no problems, I'll update the download.  Note that the version number has not changed.  The only difference between this and the current version is this archive includes the compiled version.

 

Edit:  See 1st post for download link.


Edited by Sam., 18 March 2015 - 06:40 AM.

"Ok, I've just about had my FILL of riddle asking, quest assigning, insult throwing, pun hurling, hostage taking, iron mongering, smart-arsed fools, freaks, and felons that continually test my will, mettle, strength, intelligence, and most of all, patience! If you've got a straight answer ANYWHERE in that bent little head of yours, I want to hear it pretty damn quick or I'm going to take a large blunt object roughly the size of Elminster AND his hat, and stuff it lengthwise into a crevice of your being so seldom seen that even the denizens of the nine hells themselves wouldn't touch it with a twenty-foot rusty halberd! Have I MADE myself perfectly CLEAR?!"

--<CHARNAME> to Portalbendarwinden

--------------------

post-10485-0-15080600-1348188745.jpg
___________Old pen and paper modules of the 70s and 80s.___________

CA Forums CA Homepage


#8 Miloch

Miloch

    Barbarian

  • Modder
  • 6579 posts

Posted 21 October 2014 - 01:28 PM

Cool. I may have need of this soon.


Infinity Engine Contributions
Aurora * BG1 NPC * BG1 Fixpack * Haiass * Infinity Animations * Level 1 NPCs * P5Tweaks
PnP Free Action * Thrown Hammers * Unique Containers * BG:EE * BGII:EE * IWD:EE
================================================================
Player & Modder Resources
BAM Batcher * Creature Lister * Creature Checker * Creature Fixer * Tutu/BGT Area Map & List * Tutu Mod List
================================================================
"Infinity turns out to be the opposite of what people say it is. It is not 'that which has nothing beyond itself' that is infinite, but 'that which always has something beyond itself'." -Aristotle


#9 Galactygon

Galactygon

    Modding since 2002

  • Member
  • 938 posts

Posted 09 November 2014 - 02:16 AM

I've been attempting use the already compiled version of bamresize.exe and it seems one has to drag the .bam files into the program with preset width/height settings. However I would like to change the width/height settings do you need to compile the program over and over? Or is there some place you can (a text file maybe?) where you can specify the settings? I am a n00b when it comes to python so I will have to ask for some rudimentary steps on how to run/compile this program. Thanks in advance for any help.

Edited by Galactygon, 09 November 2014 - 02:25 AM.

Posted Image

#10 The Imp

The Imp

    Not good, see EVIL is better. You'll LIVE.

  • Member
  • 5155 posts

Posted 09 November 2014 - 03:54 AM

I've been attempting use the already compiled version of bamresize.exe and it seems one has to drag the .bam files into the program with preset width/height settings. However I would like to change the width/height settings do you need to compile the program over and over? Or is there some place you can (a text file maybe?) where you can specify the settings?

This is clearly a command line tool, so you can run it with a .bat -file if you wish, just read the Usage message, or just start the cmd.exe in windows, go to the file directory(in the dos interface) and start to type command lines.


Edited by The Imp, 09 November 2014 - 04:00 AM.

Yep, Jarno Mikkola. my Mega Mod FAQ. Use of the BWS, and how to use it(scroll down that post a bit). 
OK, desert dweller, welcome to the sanity, you are free to search for the limit, it's out there, we drew it in the sand. Ouh, actually it was still snow then.. but anyways.


#11 Galactygon

Galactygon

    Modding since 2002

  • Member
  • 938 posts

Posted 09 November 2014 - 06:30 AM

Thanks very much Jarmo, got it to work as you've described.

Thought it might be helpful to post the following steps for the less geeky:
1. Create a .bat file (mybat.bat) using notepad, preferably in the same directory as python.exe in the src folder (so you don't have to type in mydirector/python.exe) that comes with the download
2. Create folders to wherever you would want the conversions to happen and write some code in your mybat.bat.
3. For example if your .bat file looks like this:
python.exe bamresize.py -p 100 -q 75 mybams\*.bam
then it will resize all .bams in the mybams folder by 100% (width) and 75% (height) if it is located in the same directory as mybat.bat. You can have multiple such command lines to handle different inputs.
4. Run the .bat file after you have finished typing the code
5. The .bams are resized and saved as FILENAMEr.bam (note the "r" suffix before .bam) for each .bam in their own folders

bamresizer takes care that all the resized frames are aligned properly when the animation is played. However you might be picky with image quality so you might need to use photoshop or similar high-end programs to resize each frame from the original .bam and paste them into the new resized .bam without worrying about getting the frames aligned.

Edited by Galactygon, 09 November 2014 - 06:32 AM.

Posted Image

#12 Sam.

Sam.
  • Administrator
  • 1335 posts

Posted 10 November 2014 - 05:50 PM

Thanks very much Jarmo, got it to work as you've described.

Thought it might be helpful to post the following steps for the less geeky:
1. Create a .bat file (mybat.bat) using notepad, preferably in the same directory as python.exe in the src folder (so you don't have to type in mydirector/python.exe) that comes with the download
2. Create folders to wherever you would want the conversions to happen and write some code in your mybat.bat.
3. For example if your .bat file looks like this:

python.exe bamresize.py -p 100 -q 75 mybams\*.bam
then it will resize all .bams in the mybams folder by 100% (width) and 75% (height) if it is located in the same directory as mybat.bat. You can have multiple such command lines to handle different inputs.
4. Run the .bat file after you have finished typing the code
5. The .bams are resized and saved as FILENAMEr.bam (note the "r" suffix before .bam) for each .bam in their own folders

bamresizer takes care that all the resized frames are aligned properly when the animation is played. However you might be picky with image quality so you might need to use photoshop or similar high-end programs to resize each frame from the original .bam and paste them into the new resized .bam without worrying about getting the frames aligned.

Glad you got it working.  Sorry I wasn't available to reply sooner.  If you make your .bat file in the same directory as bamresize.exe instead of the scr folder, your syntax becomes:

 

 bamresize.exe -p 100 -q 75 mybams\*.bam

and you can delete the whole src folder if you aren't interested in the program source code.


"Ok, I've just about had my FILL of riddle asking, quest assigning, insult throwing, pun hurling, hostage taking, iron mongering, smart-arsed fools, freaks, and felons that continually test my will, mettle, strength, intelligence, and most of all, patience! If you've got a straight answer ANYWHERE in that bent little head of yours, I want to hear it pretty damn quick or I'm going to take a large blunt object roughly the size of Elminster AND his hat, and stuff it lengthwise into a crevice of your being so seldom seen that even the denizens of the nine hells themselves wouldn't touch it with a twenty-foot rusty halberd! Have I MADE myself perfectly CLEAR?!"

--<CHARNAME> to Portalbendarwinden

--------------------

post-10485-0-15080600-1348188745.jpg
___________Old pen and paper modules of the 70s and 80s.___________

CA Forums CA Homepage


#13 Galactygon

Galactygon

    Modding since 2002

  • Member
  • 938 posts

Posted 12 November 2014 - 02:03 PM

If you are enlarging images and concerned about the quality then I could highly recommend SmillaEnlarger, which is downloadable from Sourceforge. It could even handle batch files, and is superior even to photoshop (imo) when it comes to upscaling. The only disadvantage with the upscaling is that your inputs are limited; you cannot stretch an image. The workaround is to have SmillaEnlarger do the upscaling and do any downscaling in Photoshop or something similar if you only wish to have different ratios when you resize the images. Then you need to import them as frames in .bams.

Unortunately bamworkshop 2 has issues in win8, I simply cannot select frames in photoshop and paste them in or vice versa into bamworkshop 2. Seems the copy and/or paste function there is broken. Each time I get "Access violation at address 00427044 in module 'BamWorkshop.exe'. Read of address 00000028". I did not have this issue years ago when I had a different operating system (win xp).
Posted Image

#14 The Imp

The Imp

    Not good, see EVIL is better. You'll LIVE.

  • Member
  • 5155 posts

Posted 12 November 2014 - 02:21 PM

Unortunately bamworkshop 2 has issues in win8, I simply cannot select frames in photoshop and paste them in or vice versa into bamworkshop 2. Seems the copy and/or paste function there is broken. Each time I get "Access violation at address 00427044 in module 'BamWorkshop.exe'. Read of address 00000028". I did not have this issue years ago when I had a different operating system (win xp).

I hear that you should keep all your own files and games etc you intent to edit with stuff in C:\Users\<username>\ as the rest of the folders have locked folder permissions in Windows 8 and 8.1 ... try it.


Yep, Jarno Mikkola. my Mega Mod FAQ. Use of the BWS, and how to use it(scroll down that post a bit). 
OK, desert dweller, welcome to the sanity, you are free to search for the limit, it's out there, we drew it in the sand. Ouh, actually it was still snow then.. but anyways.


#15 Sam.

Sam.
  • Administrator
  • 1335 posts

Posted 12 November 2014 - 03:53 PM

If you are looking for a way to generate a creature BAM from external image frames, I think I can help with that.  The downside is that the process involves command-line tools, and the syntax/usage is less trivial than BAM Resizer.  You will also have to calculate the new offsets for the resized frames, but as long as you are doing a pure percentile change (75%, 150%, etc.), the math is easy.  You can either update the new offsets by hand before compiling the frames into a BAM, or automate the process using a scripting language of your choice.  I would use AutoHotkey, but if you are a WeiDU ninja, you could probably do it with that.  If you are interested, shoot me a PM.


"Ok, I've just about had my FILL of riddle asking, quest assigning, insult throwing, pun hurling, hostage taking, iron mongering, smart-arsed fools, freaks, and felons that continually test my will, mettle, strength, intelligence, and most of all, patience! If you've got a straight answer ANYWHERE in that bent little head of yours, I want to hear it pretty damn quick or I'm going to take a large blunt object roughly the size of Elminster AND his hat, and stuff it lengthwise into a crevice of your being so seldom seen that even the denizens of the nine hells themselves wouldn't touch it with a twenty-foot rusty halberd! Have I MADE myself perfectly CLEAR?!"

--<CHARNAME> to Portalbendarwinden

--------------------

post-10485-0-15080600-1348188745.jpg
___________Old pen and paper modules of the 70s and 80s.___________

CA Forums CA Homepage


#16 Galactygon

Galactygon

    Modding since 2002

  • Member
  • 938 posts

Posted 13 November 2014 - 10:06 AM


Unortunately bamworkshop 2 has issues in win8, I simply cannot select frames in photoshop and paste them in or vice versa into bamworkshop 2. Seems the copy and/or paste function there is broken. Each time I get "Access violation at address 00427044 in module 'BamWorkshop.exe'. Read of address 00000028". I did not have this issue years ago when I had a different operating system (win xp).

I hear that you should keep all your own files and games etc you intent to edit with stuff in C:\Users\<username>\ as the rest of the folders have locked folder permissions in Windows 8 and 8.1 ... try it.
 
 


I found what the issue was. You have to open BamWorkshop 2 as administrator and from there open any .bam files and then you are fine copying and pasting.
If you are looking for a way to generate a creature BAM from external image frames, I think I can help with that.  The downside is that the process involves command-line tools, and the syntax/usage is less trivial than BAM Resizer.  You will also have to calculate the new offsets for the resized frames, but as long as you are doing a pure percentile change (75%, 150%, etc.), the math is easy.  You can either update the new offsets by hand before compiling the frames into a BAM, or automate the process using a scripting language of your choice.  I would use AutoHotkey, but if you are a WeiDU ninja, you could probably do it with that.  If you are interested, shoot me a PM.

I'm doing something with standardizing spell overlay animations. For example, if you have BG(II)EE's spell deflection animation playing over minor globe or even in IWD:EE you see that the animations do not fit very well because they have different sizes. Also, BG(II)EE's spell deflection animation is spherical wheras IWD(II)'s overlays are oblong-shaped so they look out of place when both play at the same time. Basically I am trying to get all such overlays (including PS:T ones) have a standard-sized spherical animation (MINORGLB.bam is what I'm shooting for), so they look nice when multiple overlays play on top of each other.

I've been having really good results with SmillaEnlarger. I could practically enlarge images 200% with them still looking crisp and sharp. See the attached example. To the left is a smaller original frame of ESHIELC.bam and to the right is the resized version of it. From there on, downscaling the frames in photoshop to make them "spherical" ala MINORGLB.bam is no problem.

Any image quality loss you see in the attachment actually comes from converting it to .jpeg format. A better way to compare is to look at the image quality of both the enlarged and the non-enlarged images.

Attached Images

  • example.jpg

Edited by Galactygon, 13 November 2014 - 10:08 AM.

Posted Image

#17 Sam.

Sam.
  • Administrator
  • 1335 posts

Posted 18 March 2015 - 06:43 AM

Update to bamresize v2.4.  See 1st post for download link.
 
v2.4 (18 March 2015)
  • Fixed a bug in the frame offset calculations of negative numbers.
  • Added option to not recalculate (scale) frame offsets with resize. ['-n' or '--norecalcoffset']
  • Added option to modify (either increment or decrement) x and y offsets by a positive or negative number. ['-x NUMBER' or '--modxoffset] and ['-y NUMBER' or '--modyoffset]
  • Added option to set x and y offsets to a positive or negative number.  ['-s NUMBER' or '--setxoffset] and ['-t NUMBER' or '--setyoffset]
  • Compiled into self-contained EXE.

Edited by Sam., 18 March 2015 - 06:45 AM.

"Ok, I've just about had my FILL of riddle asking, quest assigning, insult throwing, pun hurling, hostage taking, iron mongering, smart-arsed fools, freaks, and felons that continually test my will, mettle, strength, intelligence, and most of all, patience! If you've got a straight answer ANYWHERE in that bent little head of yours, I want to hear it pretty damn quick or I'm going to take a large blunt object roughly the size of Elminster AND his hat, and stuff it lengthwise into a crevice of your being so seldom seen that even the denizens of the nine hells themselves wouldn't touch it with a twenty-foot rusty halberd! Have I MADE myself perfectly CLEAR?!"

--<CHARNAME> to Portalbendarwinden

--------------------

post-10485-0-15080600-1348188745.jpg
___________Old pen and paper modules of the 70s and 80s.___________

CA Forums CA Homepage


#18 Sam.

Sam.
  • Administrator
  • 1335 posts

Posted 15 July 2015 - 05:22 PM

Updated to bamresize v2.8.  See 1st post for download link.

v2.5 (16 June 2015)

  • Added option to pad the frames (with transparent pixels) before resizing them to ensure the resized dimensions and offsets are uniform. This eliminates frame 'twitching' when resized. ['-u' or '--unify']
  • Added option to trim the padding (transparent pixels) from the frames after resizing them. This is the opposite of --unify. ['-t' or '--trim']
  • Removed option to not recalculate (scale) frame offsets with resize. ['-n' or '--norecalcoffset']
  • Modified the option to set the y offset to a positive or negative number to use ['-v NUMBER' or '--setyoffset] instead of ['-t NUMBER' or '--setyoffset]

v2.6 (20 June 2015)

  • Improved handling of very small frame dimensions (<= 1 px).
  • Added undocumented ['-d' or '--debug'] option to print some debug information to console.

v2.7 (22 June 2015)

  • Updated Python to v2.1.3, updated PyWin32 to Build 151, and upgraded the Python Imaging Library to v1.1.5.
  • Included installers for the above plus PyInstaller for posterity.
  • Included the entire PIL with BAM Resizer.
  • Added option to export the frames as BMPs. ['-e' or '--export']
  • Fixed several bugs in how input Options were processed.
  • Unify and Trim options are now ON by default and require a second parameter when specified: ['-u VALUE' or '--unify] and ['-t VALUE' or '--trim]
  • Unify can now pad the frames until they are square by setting the option's value to 2. ['-u 2' or '--unify]

v2.8 (06 July 2015)

  • Fixed a bug in how unify was implemented when set to square.
  • Fixed a bug where frames were being exported before being resized, not after.
  • Fixed several more bugs in how input Options were processed, resulting in them being applied in a more logical order.
  • Added option to export frames in the basic format indicated by FORMAT: ['-e FORMAT' or '--export] Examples include "bmp", "png", and "gif". Default is do not export.
  • usage.txt documentation included.

"Ok, I've just about had my FILL of riddle asking, quest assigning, insult throwing, pun hurling, hostage taking, iron mongering, smart-arsed fools, freaks, and felons that continually test my will, mettle, strength, intelligence, and most of all, patience! If you've got a straight answer ANYWHERE in that bent little head of yours, I want to hear it pretty damn quick or I'm going to take a large blunt object roughly the size of Elminster AND his hat, and stuff it lengthwise into a crevice of your being so seldom seen that even the denizens of the nine hells themselves wouldn't touch it with a twenty-foot rusty halberd! Have I MADE myself perfectly CLEAR?!"

--<CHARNAME> to Portalbendarwinden

--------------------

post-10485-0-15080600-1348188745.jpg
___________Old pen and paper modules of the 70s and 80s.___________

CA Forums CA Homepage


#19 Argent77

Argent77
  • Administrator
  • 1419 posts

Posted 05 December 2016 - 05:31 AM

bamresize v2.8 has trouble decoding the BG2EE file CDMF4G12.BAM. It terminates with the following error:

Traceback (most recent call last):
  File "<string>", line 1011, in ?
  File "<string>", line 999, in main
  File "<string>", line 478, in load
  File "<string>", line 417, in getFrames
  File "<string>", line 377, in getFrame
IOError: RLE error for frame 479: got 1090, expected 1081


Edit: Another file with similar decoding issues is WQSSPA4.BAM.


Edited by Argent77, 05 December 2016 - 06:03 AM.


#20 Sam.

Sam.
  • Administrator
  • 1335 posts

Posted 05 December 2016 - 12:09 PM

bamresize v2.8 has trouble decoding the BG2EE file CDMF4G12.BAM. It terminates with the following error:
Traceback (most recent call last):
  File "<string>", line 1011, in ?
  File "<string>", line 999, in main
  File "<string>", line 478, in load
  File "<string>", line 417, in getFrames
  File "<string>", line 377, in getFrame
IOError: RLE error for frame 479: got 1090, expected 1081


Edit: Another file with similar decoding issues is WQSSPA4.BAM.

Interesting.  NI and BAMWorkshop seem to open it ok, but BAMWorkshop II, WinBAM, and bamresize (obviously) don't.  DLTCEP throws the error message "Animation loaded with errors"

 

I have seen two different strategies used to load (and un-RLE) frame data from a BAM.  The first is to jump to OffsetToFrameData and start reading bytes.  If the frame data is RLEd, it is un-RLEd as bytes are being read until Width*Height number of bytes is reached.  The second is to read a block of data from OffsetToFrameData of the current frame to OffsetToFrameData of the next numerically higher frame data offset, then un-RLE the whole thing.  The error you have reported would make since if NI uses something analogous to the 1st method while bamresize uses something similar to the 2nd AND there are unused bytes between the blocks of frame data.  I haven't dusted off the bamresize source code to verify this yet, tho.

 

After poking CDMF4G12.BAM for a few minutes, the above scenario seems to fit.  In fact, my work-in-progress, internal-use-only BAM analyzer reports:

 

W: SizeOfFrameData>BytesReadFrameData (93184>83384)

I'll dig up bamresize off my external HD and take a look (and maybe put it on github while I'm at it...)  How urgently do you need a fix?


"Ok, I've just about had my FILL of riddle asking, quest assigning, insult throwing, pun hurling, hostage taking, iron mongering, smart-arsed fools, freaks, and felons that continually test my will, mettle, strength, intelligence, and most of all, patience! If you've got a straight answer ANYWHERE in that bent little head of yours, I want to hear it pretty damn quick or I'm going to take a large blunt object roughly the size of Elminster AND his hat, and stuff it lengthwise into a crevice of your being so seldom seen that even the denizens of the nine hells themselves wouldn't touch it with a twenty-foot rusty halberd! Have I MADE myself perfectly CLEAR?!"

--<CHARNAME> to Portalbendarwinden

--------------------

post-10485-0-15080600-1348188745.jpg
___________Old pen and paper modules of the 70s and 80s.___________

CA Forums CA Homepage






Also tagged with one or more of these keywords: bamresize, BAM