aliens

Author Topic: sprite tools  (Read 42659 times)

Offline Aldorn

  • Commander
  • *****
  • Posts: 750
    • View Profile
Re: sprite tools
« Reply #30 on: July 23, 2014, 05:47:20 pm »
if you have zipfiles that do not work please attach these here so i can take a look
For example this one, with result of conversion

A question : do you know a way to convert many GIF files to PNG (one to one) ?
« Last Edit: July 23, 2014, 05:49:54 pm by Aldorn »

Offline Falko

  • Commander
  • *****
  • Posts: 802
    • View Profile
Re: sprite tools
« Reply #31 on: July 23, 2014, 06:14:36 pm »
the files in the zipfile have defined color number 255 as transparent color
as far as i know it should be the color 0
if you google "convert many GIF files to PNG" i fopund many programs that can do that in the first page but i do not know if these tools optimizes the palette while converting the files
i myself have a python script for that

Offline Aldorn

  • Commander
  • *****
  • Posts: 750
    • View Profile
Re: sprite tools
« Reply #32 on: July 23, 2014, 06:21:53 pm »
the files in the zipfile have defined color number 255 as transparent color
ok, thanks for info

i myself have a python script for that
And do you share it ?  ::)
And provide a small tutorial to use it ?  ::) ::)
« Last Edit: July 23, 2014, 06:23:40 pm by Aldorn »

Offline yrizoud

  • Commander
  • *****
  • Posts: 1014
    • View Profile
Re: sprite tools
« Reply #33 on: July 23, 2014, 07:21:18 pm »
For conversions I can recommend XnView. There is a menu-driven interface (Tools/Batch processing) and also a command-line utility ("nconvert")

Offline Falko

  • Commander
  • *****
  • Posts: 802
    • View Profile
Re: sprite tools
« Reply #34 on: July 23, 2014, 07:24:57 pm »
there is not much magic to it
Code: [Select]
from PIL import Image
import sys,os
for args in sys.argv[1:]:
    for root,dirs,files in os.walk(args):
        for f in files:
            if f.lower().endswith(".gif"):
                im=Image.open(f)
                im.save(fn[0:-4]+".png",optimize=False,transparency=0)
if you install python and PIL (or Pillow for python 3) you could just drag and drop a/some folder of images onto the script and it creates png files where it find gif files (overwrittes existing fuiles without conformition)
still think a gui tool is prefered by most but i cant say whats best there

Offline Aldorn

  • Commander
  • *****
  • Posts: 750
    • View Profile
Re: sprite tools
« Reply #35 on: July 23, 2014, 10:07:25 pm »
For conversions I can recommend XnView. There is a menu-driven interface (Tools/Batch processing) and also a command-line utility ("nconvert")
Thanks for the info

However, I will try with python as I am really interested in learning to work with

there is not much magic to it
Code: [Select]
from PIL import Image
import sys,os
for args in sys.argv[1:]:
    for root,dirs,files in os.walk(args):
        for f in files:
            if f.lower().endswith(".gif"):
                im=Image.open(f)
                im.save(fn[0:-4]+".png",optimize=False,transparency=0)
if you install python and PIL (or Pillow for python 3) you could just drag and drop a/some folder of images onto the script and it creates png files where it find gif files (overwrittes existing fuiles without conformition)
still think a gui tool is prefered by most but i cant say whats best there
Thanks for the info, and thank you for the script, I will try it

Offline Aldorn

  • Commander
  • *****
  • Posts: 750
    • View Profile
Re: sprite tools
« Reply #36 on: July 24, 2014, 12:09:58 am »
I think I will need some help...

I installed Python 3.4
I ran easy_install-3.4.exe
I tried to install egg of PIL but it said it was already installed (2.5.1)
I create a .py file and paste your script (changed .gif to .GIF and .png to .PNG as I use uppercase extensions)
But when I drag and drop a folder containing GIF files, nothing happens
Any hint ?

EDIT : I put back gif and png instead of GIF and PNG

I succeeded taking a small (bad) screen capture of error message (1st screen shot)
I tried to rename first .GIF file to .gif but same result (2nd screen shot)
I created a folder with only one file all lowercase, same issue (3rd screen shot)
« Last Edit: July 24, 2014, 12:25:37 am by Aldorn »

Offline Falko

  • Commander
  • *****
  • Posts: 802
    • View Profile
Re: sprite tools
« Reply #37 on: July 24, 2014, 12:31:25 am »
ups slight mistake in my code ( remember test before post :) )
Code: [Select]
from PIL import Image
import sys,os
for args in sys.argv[1:]:
    for root,dirs,files in os.walk(args):
        for f in files:           
            if f.lower().endswith(".gif"):
                im=Image.open(root+os.sep+f)
                im.save(root+os.sep+f[0:-4]+".png",optimize=False,transparency=0)

Offline Aldorn

  • Commander
  • *****
  • Posts: 750
    • View Profile
Re: sprite tools
« Reply #38 on: July 24, 2014, 12:45:01 am »
This works ! :D

And this global conversion showed me all GIF files that seem to not have right palette
Thanks again

EDIT : I am now able to play with all these sprites, modify them, create new one as I wish, ... I enjoy it a lot, thanks thanks thanks thanks thanks...
« Last Edit: July 24, 2014, 12:04:10 pm by Aldorn »

Offline jStuffer

  • Squaddie
  • *
  • Posts: 3
    • View Profile
Re: sprite tools
« Reply #39 on: August 02, 2014, 12:58:28 am »
Linux users may use the ImageMagick toolset to merge a list of individual images into a spritesheet. (Win32 builds exist too, I believe)

$ montage ./hand*.gif -adjoin -geometry 32x40 -tile x1 -background transparent hadndob_unmapped.png
-- here all files beginning with hand were merged into 1-row sheet
may use -tile 32x for armor spritesheets (32 columns)

Note, that I'm naming my output 'unmapped', because the process reduces the palette, making it incompatible. Finally, this would require restoring the palette - I just paste the new spritesheet with GIMP into an existing valid image (one of the originals, with good palette), resizing it & removing the original layer; then save as new.

(manual on montage: https://www.imagemagick.org/Usage/montage/)

Offline Falko

  • Commander
  • *****
  • Posts: 802
    • View Profile
Re: sprite tools
« Reply #40 on: August 02, 2014, 02:39:46 am »
yeah i did saw the complicated gimp solution for palette fixing twice now
so i wrote a fixer for that issue
open https://falkooxc.pythonanywhere.com/palconvert
select the same palette in both dropdown menues
click more details
activate "try to fix palette colors"
and convert
that solves images with reduced palette but correct! colors that is the case in most of the wrong color- images
some images have wrong colors these colors are replaced by transparency (0) so such change should be obvious

Offline XCOMFan419

  • Colonel
  • ****
  • Posts: 183
  • Wait I'm still here I swear
    • View Profile
Re: sprite tools
« Reply #41 on: August 03, 2014, 06:55:38 pm »
So I'm trying to edit the HWP sprites for a mod that I'm making, which is a HWP compilation. I'm trying to make blue alloy tanks, and every time I've tried nothing happens and the template stays the same. I tried several times and still no dice. Mind showing me what's wrong?

I've followed the instructions in the first post by looking at docusprites and still nothing. They remain the same colour.

Offline Falko

  • Commander
  • *****
  • Posts: 802
    • View Profile
Re: sprite tools
« Reply #42 on: August 03, 2014, 07:58:16 pm »
the template i offer does not change its a template that you have to change and upload again
i hope the attached image helps
« Last Edit: August 03, 2014, 08:05:28 pm by Falko »

Offline robin

  • Commander
  • *****
  • Posts: 1226
  • ULTIMATE ROOKIE
    • View Profile
Re: sprite tools
« Reply #43 on: August 05, 2014, 11:46:23 pm »
Falko, I was using your "sprite2png" tool like there was no tomorrow, and it went down.

I hope I haven't been too rough  :P


Edit:
Ok, it just resurrected :)
« Last Edit: August 05, 2014, 11:55:00 pm by robin »

Offline Aldorn

  • Commander
  • *****
  • Posts: 750
    • View Profile
Re: sprite tools
« Reply #44 on: August 06, 2014, 12:52:12 am »
@Falko : perhaps you just ignore as it was a little bit nerving, but as you did not answer, I draw you attention at this question, especially the possibility to select an offset + size of range
« Last Edit: August 06, 2014, 12:53:55 am by Aldorn »