Skip to content

BG Portraits Creator

VagdishVagdish Member Posts: 20
edited July 2013 in General Modding
Hey guys !

I created a small tools to make cropping and resizing of portraits for BG:EE easier.
Just open a file, select the zoom (with scrollwheel) and the cropping position (with mouse drag) and save it. The name will be formatted for BG:EE, as well as the image format. You can have different cropping positions and zoom sets for the three different sizes.

I also added a batch processing. Select an input and output folder, and the job will be done for any picture file found in the input folder (and subfolder).

It's written in Python, the GUI with Tkinter, and I use Pillow for image manipulation.

The source code is here : https://github.com/Vagdish/BGPyrtraits
You can run the source code with proper installation of Python 3.3 and Pillow 2.0.0.

I Freezed the app for those who doesn't want to install Python :
(see under)
Feel free to duplicate the zip file in other file hosters.

Unzip and launch the .exe.

Feedback are more than welcome on the thread (or on the github page).

Edit:// There was a bug preventing from opening jpeg picture. It's now solved.

Edit:// Here is the last version of the software: https://github.com/Vagdish/BGPyrtraits/releases/1.01/2573/BGPyrtraits-1.01.zip
Post edited by Vagdish on
«1

Comments

  • Troodon80Troodon80 Member, Developer Posts: 4,110
    Very handy :).
  • KaltzorKaltzor Member Posts: 1,050
    Would be better if you could have separate cropping for the small portrait... As I personally like my portraits the Icewind Dale style where the Medium/Large ones are a full body one and the small one is the head.
  • VagdishVagdish Member Posts: 20
    You can. There is a "connect/disconnect" button. Pictures are connected at startup, but if you hit the button, you'll see that medium and small pictures can be changed alone.

    But your comment points out that it's not obvious. I'll try to improve that.
  • smeagolheartsmeagolheart Member Posts: 7,963
    @Vagdish

    It looks great. 2 additional feature questions...

    Is there anyway to use this from the command line so that it could be run from Weidu for example?

    and is it possible to add a config file or option to select old BG portrait sizes (38x60 s and 110x170 m) in addition to the BGEE sizes?

    One of the problems I've run into in making mods is I'd prefer not to include two sets of portraits, if weidu could use this to generate appropriate sized portraits when people install a mod, it would be great.
  • VagdishVagdish Member Posts: 20
    edited June 2013
    Heya,

    Thanks for the feedbacks.
    Here is a new version of the software. If called without any arguments, it launches the GUI. If called from command line with 3 arguments, it doesn't launch the GUI, and do the conversion.
    - First argument is either "--newstyle" or "--oldstyle" and define the size of the exported pictures (BGEE sizes and old BG 38x60 and 110x170 sizes respectively).
    - Second argument is the input file (absolute or relative path)
    - Third argument is the output files (absolute or relative path)

    No "oldstyle" export from the GUI, don't think it's relevant for now.
    No batch from command line. I don't know if you need one.

    http://www.filedropper.com/showdownload.php/bgpyrtraits_2

    I need feedback as I don't really know your exact needs for Waidu/mods.

    Thanks
    Post edited by Vagdish on
  • smeagolheartsmeagolheart Member Posts: 7,963
    Vagdish said:

    Heya,

    Thanks for the feedbacks.
    Here is a new version of the software. If called without any arguments, it launches the GUI. If called from command line with 3 arguments, it doesn't launch the GUI, and do the conversion.
    - First argument is either "--newstyle" or "--oldstyle" and define the size of the exported pictures (BGEE sizes and old BG 38x60 and 110x170 sizes respectively).
    - Second argument is the input file (absolute or relative path)
    - Third argument is the output files (absolute or relative path)

    No "oldstyle" export from the GUI, don't think it's relevant for now.
    No batch from command line. I don't know if you need one.

    http://www.filedropper.com/showdownload.php/bgpyrtraits_2

    I need feedback as I don't really know your exact needs for Waidu/mods.

    Thanks

    @Jalily @Vagdish

    The exact weidu use I have in mind for this would be to take a folder with 400 BGEE small size portraits(54x84) and use something from the command line to shrink them to non-destructively copy and create 38x60 sized in a different folder. (this would be useful for the "faces mod" http://forum.baldursgate.com/discussion/18421/bgee-mod-weidu-faces-by-irbis-jalily/p1 ) as well as my mod.

    Alternatively, a tool like this could with a folder full of 210x330 sized portraits to generate the 2 additional sizes (as it does now). That way people could make portrait mods and only include large sized portraits and weidu could launch an external command depending on the install detected to generate the 2 additional sizes.
  • VagdishVagdish Member Posts: 20
    edited June 2013
    Ok,

    Best way to do this is to add 2 (command-line) executables, one for each job.
    'Will do that in a week.

    Problem is I want to do it in Python (as I want to improve myself in Python in some area. threads, tkinter, pillow in this case). Without any Python installation, the distributed executables/libraries are heavy (6 Mo zipped). Doing it in C would have been lighter.

    So is it still useful to have these executables in a ~10 Mo folder ? Should I do it in Python ? I could do it in C but I don't really want to (no offense but I'm doing this application for mysel first, then for the BG community).
  • smeagolheartsmeagolheart Member Posts: 7,963
    @Vagdish

    Do it how you want. It would be nice if whatever you end up with is cross-platform runnable I guess because there might be people with Macs and PCs and IPads and android tablets trying to run this. Not all those platforms can run mods anyway, however, Mac and PC at least are running mods.. Sorry you know more about the details than I do! I don't know if C or Python would be better in that case?
  • VagdishVagdish Member Posts: 20
    C and Python can both be used on PC/Mac. C may requires more time and more rigorous coding to make it cross-platform. But you get a smaller exec.
    If it doesn't bother you to include an archive like the one I distribute (the exec must be distributed with its own library), then I'll do it in Python.

    I'll post here for updates...
  • smeagolheartsmeagolheart Member Posts: 7,963
    it doesn't bother me a bit, the program would get a separate folder and it doesn't matter how many files are in it. Overall size is somewhat of an issue as it's best to keep download size small normally as the idea is to reduce the number of pictures attached to a mod. If the exe is greater than the size of duplicating the pictures then it's not as desirable, though for me I'd still rather generate on the fly the portraits than duplicate them.
  • dlnorthcdlnorthc Member Posts: 4
    Really cool program but when trying to do a large batch of pictures (around 4000) it crashes in the first few seconds every time.

    Seems like it will be a great util when you get it working :)
  • VagdishVagdish Member Posts: 20
    @smeagolheart
    I have the program working in command line, doing what you told me. I'll upload it in few hours.

    @dlnorthc
    I must admit I didn't test it with such a huge collection. It works well for ~100 pictures. Can you test with around 100 pictures ? Is it working ? It may become from a corrupted/bad formatted pictures, or from a bad memory management.

    I'll try with the portraits dropbox repository...
  • VagdishVagdish Member Posts: 20
    edited June 2013
    @dlnorthc
    Ok, I investigated the problem. If some files are corrupted, they are still opened, and trying to resize and save them can cause the application to crash.

    In addition, png files with transparency are loaded and saved as bmp file without removing the transparency (bmp files don't handle transparency).

    Everything should work fine now, can you run again a batch processing with your portraits library with the new build ?

    @smeagolheart
    With command line, you have access to two options:
    BGPyrtraits.exe --smallee inputfolder outputfolder
    BGPyrtraits.exe --genms inputfolder outputfolder

    First one take ANY pictures in folder AND subfolders, and resize them to BG (old) small size 38x60, without taking care of the name (just copy the source file name)
    Second command take ANY pictures in folder AND subfolders, and resize them to BGEE medium and small size. It replaces the "L" in the file name by "M" and "S" respectively to the new image size.

    http://www.filedropper.com/bgpyrtraits10

    App folder is 12 Mo, zip file is 5 Mo.
    Post edited by Vagdish on
  • smeagolheartsmeagolheart Member Posts: 7,963
    @Vagdish that looks as if it would work perfectly..
  • VagdishVagdish Member Posts: 20
    That's good to know !

    I hope I solved the crash reported by @dlnorthc
  • dlnorthcdlnorthc Member Posts: 4
    Vagdish said:

    @dlnorthc
    Ok, I investigated the problem. If some files are corrupted, they are still opened, and trying to resize and save them can cause the application to crash.

    In addition, png files with transparency are loaded and saved as bmp file without removing the transparency (bmp files don't handle transparency).

    Everything should work fine now, can you run again a batch processing with your portraits library with the new build ?

    @smeagolheart
    With command line, you have access to two options:
    BGPyrtraits.exe --smallee inputfolder outputfolder
    BGPyrtraits.exe --genms inputfolder outputfolder

    First one take ANY pictures in folder AND subfolders, and resize them to BG (old) small size 38x60, without taking care of the name (just copy the source file name)
    Second command take ANY pictures in folder AND subfolders, and resize them to BGEE medium and small size. It replaces the "L" in the file name by "M" and "S" respectively to the new image size.

    http://www.filedropper.com/bgpyrtraits10

    App folder is 12 Mo, zip file is 5 Mo.

    Awesome! Works great now! Wish I knew how to +1 your rep or something :D Thanks so much lol, love the new changes you made to it
  • VagdishVagdish Member Posts: 20
    @dlnorthc
    I'm very glad to hear that. Thank you for your feedback. Without it, the bug would still be there !

    @smeagolheart
    Keep me aware of anything you'll do with my piece of software ;)
  • smeagolheartsmeagolheart Member Posts: 7,963
    @Vagdish , well I had intended to see about integration into the Faces Mod! but had not yet started
  • smeagolheartsmeagolheart Member Posts: 7,963
    also had hoped to use it in my mods now and in the future, this ok?
  • VagdishVagdish Member Posts: 20
    I just expected the software to be used by players to make creation of portraits easier. I'm very glad that someone uses it in a mod. Use it at your pleasure !

    (I wouldn't have done the modifications if I didn't wanted you to use it in a mod)
  • smeagolheartsmeagolheart Member Posts: 7,963
    If I do use it, I will certainly attribute the conversion software to you
  • smeagolheartsmeagolheart Member Posts: 7,963
    edited June 2013
    @Vagdish

    I'm trying this out. I have a 210x330 and would like to generate L and S from cmd line at oldsizes (110x170 and 38x60). Not possible?

    I tried this and nothing seemed to happen:
    BGPyrtraits --oldstyle D:\Games\BGT\BGT\DVD\Art\BARB_4f.bmp c:\Users\Mark\Downloads\BGPyrtraits

    also there are 3 versions? of your upload here in this thread including 2 in the first post... Which one should I use?
  • VagdishVagdish Member Posts: 20
    I'm sorry, I admit I'm confusing you with too much versions of the program.

    You should use http://www.filedropper.com/bgpyrtraits10
    But --oldstyle doesn't exists anymore. Only these exist :
    BGPyrtraits.exe --smallee inputfolder outputfolder (generate "old" S size from any pictures)
    BGPyrtraits.exe --genms inputfolder outputfolder (generate "EE" M and L sizes from any pictures)

    I see that you need to generate "old" L and S from pictures, and that cannot be done by command line yet.
    I'll do it as soon as possible.
  • smeagolheartsmeagolheart Member Posts: 7,963
    BGPyrtraits.exe --smallee inputfolder outputfolder (generate "old" S size from any pictures)
    this is useful as is.

    Can you add one more instead of taking this one away? One that generates small and medium BGT sizes.

    also question:
    --genms inputfolder outputfolder (generate "EE" M and L sizes from any pictures) <- EE S and M sizes?
  • VagdishVagdish Member Posts: 20
    Yup, sorry, --genms generate "EE" S and M, not M and L.

    I'll readd --oldstyle asap. (Just after work).
  • VagdishVagdish Member Posts: 20
    I generated a new version. You can find it here :
    http://www.filedropper.com/bgpyrtraits11

    I added --oldstyle argument, which is followed by input folder and output folder.
    The software will take any pictures in folder and subfolders, and resize each one of them to the "old" BG sizes. Be careful though, It doesn't take care of any name duplicate. First 7 letters of the input names must be different. (But the batch processing via GUI take care of duplicate names).

    Suffixes are "L" and "S", is it correct ?
  • smeagolheartsmeagolheart Member Posts: 7,963
    edited June 2013
    L&S are BG1 standard while BG2 seems to be M&S.

    I would suggest using BG2 M and S. L in BG2 is the TOB epilogue size (210x330)..

    http://portraits.chosenofmystra.net/npc_portrait_change.html
  • smeagolheartsmeagolheart Member Posts: 7,963
    edited June 2013
    @Vagdish

    I got it to work once I stopped trying to use a filename and used a folder instead. The resulting portraits were horribly pixelated? (same photo renamed)
    image
  • VagdishVagdish Member Posts: 20
    Can you attach the file so I can test and debug ?
  • smeagolheartsmeagolheart Member Posts: 7,963
    Here it is
Sign In or Register to comment.