Author Topic: Simutrans Tools for GIMP ver. 0.7  (Read 15609 times)

0 Members and 1 Guest are viewing this topic.

Offline Fabio

  • Devotee
  • Administrator
  • *
  • Posts: 2898
  • Total likes: 7
  • Helpful: 91
  • The Pak128 Guy
    • Visit me on Facebook
  • Languages: EN, IT, RO, FR
Simutrans Tools for GIMP ver. 0.7
« on: March 08, 2012, 06:46:59 PM »
Hello,

I've been busy these days creating a Script-FU for GIMP.

Shades is great, but it processes PNGs, so I can only use it for post-processing the exports from GIMP.
I really missed a tool to deal with special colors directly within my XCF file. This is how this script was thought.

It offers several functions, among which:
- Select special special colors
- Remove special special colors
- Repair special special colors
- Lighten/Darken special colors
- Convert (lookup) special colors
- Isometric surfaces helper


Select special colors does as it says.
Remove special colors replaces special colors with very similar ones.
Repair special colors looks for colors similar to the special ones within a threshold (default 15%) and replaces them with the special colors.

You can chose to work on 6 different groups:
- Non-darkening greys
- Windows
- Primary player colors
- Secondary player colors
- Lights
- Transparency (E7FFFF)

You can work on current layer or recursively on all layers. There is a current limitation that it doesn't work (yet) on special colors (accidentally) resulting from combining two different layers (typically a shadow). I'll work on this next.
Special colors (accidentally) resulting from combining two different layers (typically a shadow) can be selected but not (yet?) automatically removed.



Screenshots:











Download:

simutrans-tools-for-gimp-0_7.zip (ver. 0.7)



How to install:

Just unzip and copy in
C:\Program Files\GIMP-2.0\share\gimp\2.0\scripts
or in
~\.gimp-2.6\scripts (e.g. C:\Documents and Settings\Administrator\.gimp-2.6\scripts)
Then start GIMP or refresh Script-Fu's.
« Last Edit: July 03, 2012, 07:23:54 PM by Fabio »

Offline Carl

Re: Simutrans Special Colors Helper for GIMP
« Reply #1 on: March 08, 2012, 07:13:33 PM »
This looks great, thanks Fabio! Looking forward to trying it out!

Offline wlindley

Re: Simutrans Special Colors Helper for GIMP
« Reply #2 on: March 09, 2012, 04:18:28 PM »
YAY!   Excellent...

How hard would it be, for makeobj to regard png transparency, that would make painting so much easier, wouldn't it?

Offline Fabio

  • Devotee
  • Administrator
  • *
  • Posts: 2898
  • Total likes: 7
  • Helpful: 91
  • The Pak128 Guy
    • Visit me on Facebook
  • Languages: EN, IT, RO, FR
Re: Simutrans Special Colors Helper for GIMP
« Reply #3 on: March 09, 2012, 05:23:26 PM »
Thank you!

I updated the first post with the link to new release 0.2

FIX it painted all screen if the color was not found
CHG some optimization
CHG progress bar now working

Offline prissi

  • Developer
  • Administrator
  • *
  • Posts: 8821
  • Total likes: 322
  • Helpful: 229
  • Languages: De,EN,JP
Re: Simutrans Special Colors Helper for GIMP
« Reply #4 on: March 09, 2012, 11:16:35 PM »
Transparency would not help; only if you use 100% and 0% transparency. But usually render program generate anything but that. (You can do masks in Gimp from transparency, then set thm to black/white for background generation.)

Offline Packer

  • *
  • Posts: 101
  • Total likes: 0
  • Helpful: 3
  • Download PakUS. Download Pak US. Download Pak US.
  • Languages: EN
Re: Simutrans Special Colors Helper for GIMP
« Reply #5 on: March 12, 2012, 03:10:48 PM »
Neat tool for GIMP. Might give it another go-around

I saw this thread and am curious if modifying the tool could result in something that would aid me greatly with the vehicles I'm working on (see F45 thread). I was wondering if it would it be possible to modify or tweak it to change colors from the TTD template to the Simutrans template? I've been doing it manually using a template I made; but having a tool to do it would speed up my work on pakUSA (my unofficial pet project) greatly.
The Pack is back!!

Pak64US vehicles, goods files, road, and terrain tiles: download here
Pak64US would greatly appreciate helpers to get it off the ground:Please Help

Offline Fabio

  • Devotee
  • Administrator
  • *
  • Posts: 2898
  • Total likes: 7
  • Helpful: 91
  • The Pak128 Guy
    • Visit me on Facebook
  • Languages: EN, IT, RO, FR
Re: Simutrans Tools for GIMP 0.4
« Reply #6 on: March 13, 2012, 12:06:35 PM »
New release.

Renamed the project to Simutrans Tools for GIMP, as it is now intended to have more functions (you can also suggest a better name).

Added a new tool: Export with transparency. This will allow you to work on transparent images forgetting the special color E7FFFF. Just export with this tool to have a special color background added and half transparent colors removed or opaque (you can set a threshold).

Fixed an ugly bug which made the script only work on the first image open in GIMP.

Made some more changes in the code, as I'm learning Scheme better ;)



Changelog:

;; SIMUTRANS TOOLS FOR GIMP 0.4
;;
;; ver. 0.4 - 13/03/2012
;; ADD PNG Export tool
;; FIX Remove and Repair only worked on first open image (image id=1)
;;
;; ver. 0.2 - 09/03/2012
;; FIX it painted all screen if the color was not found
;; CHG some optimization
;; CHG progress bar now working
;;
;; ver. 0.1 - 08/03/2012
;; initial release




@wlindley: you can test the new tool! Just make a backup copy of your file before if you use PNG, no risk if you're using XCF format.

@packer: interesting idea, and easy to implement. I would like to make a more general purpose tool, though, than a simple TTD importer... I will think about something, but I'm open to suggestion.
« Last Edit: March 15, 2012, 06:26:59 PM by fabio »

Offline Packer

  • *
  • Posts: 101
  • Total likes: 0
  • Helpful: 3
  • Download PakUS. Download Pak US. Download Pak US.
  • Languages: EN
Re: Simutrans Tools for GIMP 0.4
« Reply #7 on: March 13, 2012, 12:35:16 PM »
...
@packer: interesting idea, and easy to implement. I would like to make a more general purpose tool, though, than a simple TTD importer... I will think about something, but I'm open to suggestion.

Hearing that it'd be easy to implent is good. A color general converison tool would work just as well.

A tool that could allow converting any x-amount of colors to any x-amount of other colors withing a specified area would be a big help. If you look at my conversion template; I usually use 8 colors to represent the shades of a particular color. (I use it for player colors, gray, black, yellow,and special colors. I sometimes have difficulty telling some of the colors apart (hence I have a gray, black, and yellow template). As a result and on some occasion if I'm starting something from scratch; I'll use wildly contrasting colors the convert them manually afterwards.
The Pack is back!!

Pak64US vehicles, goods files, road, and terrain tiles: download here
Pak64US would greatly appreciate helpers to get it off the ground:Please Help

Offline colonyan

Re: Simutrans Tools for GIMP ver. 0.4
« Reply #8 on: March 14, 2012, 04:03:23 AM »
Thank you very much for making this tool! I can not wait to use this tool.

Offline Fabio

  • Devotee
  • Administrator
  • *
  • Posts: 2898
  • Total likes: 7
  • Helpful: 91
  • The Pak128 Guy
    • Visit me on Facebook
  • Languages: EN, IT, RO, FR
Simutrans Tools for GIMP ver. 0.5
« Reply #9 on: March 15, 2012, 06:26:41 PM »
New release, many new features here!

Special Color Helper has now more choices.

- Convert to special colors:
as requested by Packer, it looks up special colors in a user-specified image file and replaces accordingly.
The lookup image must have one or more pair(s) of rows (or columns), the top (or left) row of the pair must contain a Simutrans special color sample, the bottom (or right) the color to be replaced (e.g. TTD's special color). The samples can have any size, but strictly all the same. The cells can be divided by a thin border, but they must be aligned. The script recognizes the orientation: default is rows, but if image height is greater than width, it assumes it's columns. See also the png in the release zip.

- Lighten / Darken:
except transparency and lights (split from windows), you can lighten or darken any set of special colors. All colors are shifted one position towards light or dark (except obviously the lightest or the darkest, respectively).

- Sample merged selection:
now you can choose to sample merged (limited to selection operation) from Layers combo. Thus you can see (but not fix automatically) which pixels will be exported as special colors, e.g. due to shadows.

Other significant changes:

- Export tool has now the option to apply a threshold to half-transparent pixels. It used to do it by default, but it slows down excessively on huge images.

- New tool to swap 2 arbitrary colors.

- New tool to set grid to tilesize and optionally resize the image to be read by makeobj.

Download link and screenshots are in the first post.



Changelog:

;; SIMUTRANS TOOLS FOR GIMP 0.5
;;
;; ver. 0.5 - 15/03/2012
;; ADD Lookup (convert) operation in Special Color Helper
;; ADD Lighten/Darken operation in Special Color Helper
;; ADD Special Color Helper sample merged select
;; ADD Set grid tool (optional resize)
;; ADD Swap colors tool
;; ADD internal stats, selection-save, selection-by-color, selection-fill
;;     and color-lookup functions
;; CHG Export flatten now optional (saves time for large images if not needed)
;; CHG code optimization

Offline Packer

  • *
  • Posts: 101
  • Total likes: 0
  • Helpful: 3
  • Download PakUS. Download Pak US. Download Pak US.
  • Languages: EN
Re: Simutrans Tools for GIMP ver. 0.5
« Reply #10 on: March 26, 2012, 03:09:29 PM »
Thanks a bunch for the color converter Fabio! This will be a great help to me in creating Pak.USA
The Pack is back!!

Pak64US vehicles, goods files, road, and terrain tiles: download here
Pak64US would greatly appreciate helpers to get it off the ground:Please Help

Offline mEGa

  • 2D painter
  • Devotee
  • *
  • Posts: 1041
  • Total likes: 1
  • Helpful: 35
  • Pak128 graphics
    • mEGa_Simutrans
  • Languages: FR, EN, ru
Re: Simutrans Tools for GIMP ver. 0.5
« Reply #11 on: March 27, 2012, 04:07:39 PM »
Hi Fabio and community
 
 I 'm just going to test your gimp converter tools. Thank you, it is great... And I 'll win more time now :-), specially for repairing special colors !
 
 If you want, one very very modest contribution : a palette of simutrans color base
 put it on ~/gimpxxx/palettes
 
Current projects in progress : improvements of few designed french paks

Offline Fabio

  • Devotee
  • Administrator
  • *
  • Posts: 2898
  • Total likes: 7
  • Helpful: 91
  • The Pak128 Guy
    • Visit me on Facebook
  • Languages: EN, IT, RO, FR
Re: Simutrans Tools for GIMP ver. 0.5
« Reply #12 on: March 27, 2012, 04:16:34 PM »
Thank you all for your feedback.

The tools were born mainly for my convenience, but then I tried to develop it to something useful for the whole community.

My favourite tools are Remove (for all the glowing at night!), Repair (used few, but saves a lot of hassle), Color swap and Darken/lighten.

Do you have any extension requests? Maybe some could be easily added to the existing code. I wish I could make this tools as more general-purposed as possible...

Offline ӔO

  • Devotee
  • *
  • Posts: 2345
  • Total likes: 2
  • Helpful: 66
  • Hopefully helpful
  • Languages: en, jp
Re: Simutrans Tools for GIMP ver. 0.5
« Reply #13 on: May 14, 2012, 10:52:30 AM »
I thought it was pretty good.
It made my life much easier modifying something to use player colours.

If I have any qualms, it's that the pallet from mEGa does not have labels as which special colour it is.
My Sketchup open project sources
various projects rolled up: http://dl.dropbox.com/u/17111233/Roll_up.rar

Colour safe chart:

Offline mEGa

  • 2D painter
  • Devotee
  • *
  • Posts: 1041
  • Total likes: 1
  • Helpful: 35
  • Pak128 graphics
    • mEGa_Simutrans
  • Languages: FR, EN, ru
Re: Simutrans Tools for GIMP ver. 0.5
« Reply #14 on: May 14, 2012, 12:31:57 PM »
If I have any qualms, it's that the pallet from mEGa does not have labels as which special colour it is.

Oh yes, could you help me to create them ?
Current projects in progress : improvements of few designed french paks

Offline Fabio

  • Devotee
  • Administrator
  • *
  • Posts: 2898
  • Total likes: 7
  • Helpful: 91
  • The Pak128 Guy
    • Visit me on Facebook
  • Languages: EN, IT, RO, FR
Simutrans Tools for GIMP ver. 0.6
« Reply #15 on: June 19, 2012, 11:42:25 AM »
Many new tools in this release 0.6.

- Multilayer tools
These tools are not only Simutrans related, but address what IMHO is a serious flaw in Gimp, which lacks a way to operate on different layers simultaneously.
Move multilayer: giving an x and y offset it moves the selection in all chosen layers. Useful when realigning a multilayer image.
Copy/Cut multilayer and Paste multilayer: copy/cuts and paste the selection in all chosen layers. Useful when you need to duplicate a tile based on several layers. Being based on layer names, pasting on a different image is restricted. These tools don't interact with normal copy/cut/paste functions.
All these tools accept a layers selection using a Regular Expressions field, so if you write ^01 you'll only copy (or move) from the layers which name starts with 01.

- Isometric surface
You can transform any front view surface into an isometric wall (south/left or east/right) or floor (south-north direction at the moment).
Useful for textures or even objects like arches and so on. It doesn't have any interpolation or antialiasing, so the result is likely to need to be manually edited. It's inspired by these scripts by froGgy factory (http://registry.gimp.org/node/25043 and http://registry.gimp.org/node/25040) but the code was written independently.

- Other updates
Switch colors can now use the current foreground/background colors instead of the two arbitrarily picked ones.
Set grid tool now supports Pak160 as well (for AEO's PakBox) and resizes all image sized layers as well as the canvas.
Menu was rearranged, but still it's not the final one.

- Future goals
The huge Special Colors Helper tool will likely be split in more specialized tools with easier UI and enhaced performance.
I'm glad to receive any extension request for this tools collection.


Download here:
simutrans-tools-for-gimp-0_6.zip (ver. 0.6)
or in the first post (updated).


Changelog:
;; SIMUTRANS TOOLS FOR GIMP 0.6
;; ============================================================================================
;;
;; ver. 0.6 - 27/04..19/06/2012
;; CHG Menu reordering
;; ADD New Isometric surface tool
;; CHG Set grid also for Pak160 and (optional) resizes image sized layers
;; CHG Swap colors can also use active front/back colors
;; ADD Copy/Cut and Paste multilayer tools
;; ADD Move multilayer tool
;;


Offline ӔO

  • Devotee
  • *
  • Posts: 2345
  • Total likes: 2
  • Helpful: 66
  • Hopefully helpful
  • Languages: en, jp
Re: Simutrans Tools for GIMP ver. 0.6
« Reply #16 on: June 19, 2012, 12:03:32 PM »
woohoo, thanks fabio.
I'll try it out this week.
My Sketchup open project sources
various projects rolled up: http://dl.dropbox.com/u/17111233/Roll_up.rar

Colour safe chart:

Offline kierongreen

Re: Simutrans Tools for GIMP ver. 0.6
« Reply #17 on: June 19, 2012, 12:26:22 PM »
Just to say this tool has been very useful over the last few weeks :)

Offline mEGa

  • 2D painter
  • Devotee
  • *
  • Posts: 1041
  • Total likes: 1
  • Helpful: 35
  • Pak128 graphics
    • mEGa_Simutrans
  • Languages: FR, EN, ru
Re: Simutrans Tools for GIMP ver. 0.6
« Reply #18 on: June 19, 2012, 03:08:30 PM »
I began to test. Great  ! Major distinction for isometric surface tool. It will be really useful for me.
I'll try more this week end.
Current projects in progress : improvements of few designed french paks

Offline VS

  • Senior Plumber (Devotee)
  • Devotee
  • *
  • Posts: 4849
  • Total likes: 25
  • Helpful: 63
  • Vladimír Slávik
    • VS's Simutrans site
  • Languages: CS,EN
Re: Simutrans Tools for GIMP ver. 0.6
« Reply #19 on: June 21, 2012, 06:39:39 PM »
Just out of curiosity, what functionality is this still missing, compared to Shades? Of course, the workflows are really different, but the end result is what I'm after...

I am contemplating just stopping development of Shades (Or rather not picking it up ever again). It was nice, and mine, but it has also come to an end, it seems.

My projects... Tools for messing with Simutrans graphics. Graphic archive - templates and some other stuff for painters. Development logs for most recent information on what is going on. And of course pak128!

Offline Fabio

  • Devotee
  • Administrator
  • *
  • Posts: 2898
  • Total likes: 7
  • Helpful: 91
  • The Pak128 Guy
    • Visit me on Facebook
  • Languages: EN, IT, RO, FR
Re: Simutrans Tools for GIMP ver. 0.6
« Reply #20 on: June 21, 2012, 07:34:02 PM »
VS, you're far too kind.

What this tool lacks is an important feedback I would like to receive, too.

What I know it's missing is:

1) night preview. here I would really appreciate hints how much regular colours are darkened at night. I could make a night preview of visible layers in a new temporary image.

2) highlighting special colours. It could be done as above.

3) localization. I'm not a fan of it, but it could be done, as gimp has a standard way to localize scripts and plugins.

4) a better way to deal with special colours resulting from combined semi-transparent layers. I'm pondering how to do it without too long processing time.

I would like to add also some tilecutter tools, but this is a goal far in time.
I would also like to split big images in a Makeobj friendly way (one object per file), but I'm stuck at parsing the dat file.

Latest improvement which I'll release soon is better creation of isometric floor.

Offline VS

  • Senior Plumber (Devotee)
  • Devotee
  • *
  • Posts: 4849
  • Total likes: 25
  • Helpful: 63
  • Vladimír Slávik
    • VS's Simutrans site
  • Languages: CS,EN
Re: Simutrans Tools for GIMP ver. 0.6
« Reply #21 on: June 21, 2012, 07:58:34 PM »
Kind? More like lazy :) Anyway, apart from the (obviously unavoidable) lack of performance, it works really well...

My projects... Tools for messing with Simutrans graphics. Graphic archive - templates and some other stuff for painters. Development logs for most recent information on what is going on. And of course pak128!

Offline Fabio

  • Devotee
  • Administrator
  • *
  • Posts: 2898
  • Total likes: 7
  • Helpful: 91
  • The Pak128 Guy
    • Visit me on Facebook
  • Languages: EN, IT, RO, FR
Re: Simutrans Tools for GIMP ver. 0.6
« Reply #22 on: June 21, 2012, 09:20:44 PM »
Thanks! The code could still be optimized, especially all colour tools which I coded first.
Later tools work on a temporary image without undo memory and are pasted back in the main image saving a lot of memory footprint and hence time. I'll extend this method to colour tools as well.
I learnt scheme language for this project, so obviously code quality and performance improves as I code more.
Also at first I planned few tools with more functions, and UI was cumbersome, now I'm planning to split some of them in faster, more intuitive and easier to maintain tools.

Offline Fabio

  • Devotee
  • Administrator
  • *
  • Posts: 2898
  • Total likes: 7
  • Helpful: 91
  • The Pak128 Guy
    • Visit me on Facebook
  • Languages: EN, IT, RO, FR
Re: Simutrans Tools for GIMP ver. 0.7
« Reply #23 on: July 03, 2012, 07:22:21 PM »
New update: version 0.7 is out!

This updates the isometric surface tool.

You can convert any surface type (front image, floor tile, wall, normal slope) into any other, or into itself. These transformation can apply rotation or flipping.
Conversion has 3 detail levels: true to pixel (level 0) or with interpolation, which till now distorts a bit the borders.
Source image can be autodetected in a canny way, so you can only specify the destination surface.
I appreciate any feedback, in order to improve the tool.

simutrans-tools-for-gimp-0_7.zip (ver. 0.7)

Offline Markohs

  • DevTeam, Coder/patcher
  • Devotee
  • *
  • Posts: 1559
  • Total likes: 2
  • Helpful: 86
  • Languages: EN,ES,CAT
Re: Simutrans Tools for GIMP ver. 0.7
« Reply #24 on: May 21, 2013, 09:25:35 AM »
Thx for writing this tool Fabio, it has been very useful to me. ;)

Offline mEGa

  • 2D painter
  • Devotee
  • *
  • Posts: 1041
  • Total likes: 1
  • Helpful: 35
  • Pak128 graphics
    • mEGa_Simutrans
  • Languages: FR, EN, ru
Re: Simutrans Tools for GIMP ver. 0.7
« Reply #25 on: May 21, 2013, 05:56:48 PM »
yes indeed. I use it too with many enjoy. Thank you Fabio ;-)
Current projects in progress : improvements of few designed french paks

Offline Raiser

Re: Simutrans Tools for GIMP ver. 0.7
« Reply #26 on: May 28, 2013, 08:53:32 PM »
Hi Fabio, thanks for writing this tool also from my side.

Two ideas for improving the isometric surface tool: convert textures/images to half-tile slopes and convert textures to isometric roof with freely adjustable angle.

Also a possibility to shade front view textures into simutrans s/w/n/e and "top tile view" lightening would be interesting.

Offline Freahk

Re: Simutrans Tools for GIMP ver. 0.7
« Reply #27 on: October 28, 2016, 06:47:19 PM »
Hi Fabio
these scripts are really useful!
I don't know if it's possible but it would be nice if this script could automatically create a Palette including all of the Simutrans special colors.