It is currently Tue Jul 14, 2026 10:47 pm


All times are UTC - 5 hours [ DST ]



Post new topic Reply to topic  [ 31 posts ]  Go to page Previous  1, 2
Author Message
 Post subject: Re: Assembling tiles based on co-ordinates in the file name.
PostPosted: Thu Aug 28, 2014 6:14 pm  (#21) 
Offline
GimpChat Member

Joined: Jul 19, 2014
Posts: 31
Anyway, shouldn't this extension to the script be a case of something like:

var parentFolder as string
for parentFolder get subfolders

for each subFolder in parentFolder,
  run originalScript(subFolder)
  purge swapFile
  purge memory

...except in Python? :)


Top
 Post subject: Re: Assembling tiles based on co-ordinates in the file name.
PostPosted: Thu Aug 28, 2014 6:30 pm  (#22) 
Offline
Script Coder
User avatar

Joined: Oct 25, 2010
Posts: 4812
AFAIK there is no scripting API (script-fu or python-fu) to "purge" the swap ("purging the memory" makes even less sense). I don't think the swap file is shrunk explicitly when an image is closed, but the space freed is likely to be reused later for other images if needed.

And anyway, given the execution times you experience, Gimp shutdown/startup is negligible so it wouldn't be less efficient to start Gimp on each directory (in other words, do the directory loop in a shell script that calls Gimp).

_________________
Image


Top
 Post subject: Re: Assembling tiles based on co-ordinates in the file name.
PostPosted: Fri Aug 29, 2014 6:08 pm  (#23) 
Offline
GimpChat Member

Joined: Jul 19, 2014
Posts: 31
ofnuts wrote:
...I don't think the swap file is shrunk explicitly when an image is closed, but the space freed is likely to be reused later for other images if needed.

I'm sure this is what's supposed to happen, but on Windows it doesn't. (You also can't move the swap file on Windows because the setting is never remembered.) It'll be a relief to set this task going in Debian 7. Hopefully someone can help before I go on holiday so I can leave the PC processing over the week. Then I guess I'll be finished :)


Top
 Post subject: Re: Assembling tiles based on co-ordinates in the file name.
PostPosted: Tue Sep 02, 2014 10:51 am  (#24) 
Offline
Script Coder
User avatar

Joined: Oct 25, 2010
Posts: 4812
Just came across this and this.

_________________
Image


Top
 Post subject: Re: Assembling tiles based on co-ordinates in the file name.
PostPosted: Tue Sep 02, 2014 3:46 pm  (#25) 
Offline
GimpChat Member

Joined: Jul 19, 2014
Posts: 31
GraphicsMagick is meant to be quite nice. I have it installed but wasn't able to get a script working.

One thing I'm still doing manually is converting the images to Indexed Colour, with a pre-set palette of 250 or 216 colours depending on the source. Would it be more efficient to do the tile assembly in Indexed Colour mode instead of converting at the end? I'm also removing the Alpha Channel and replacing it with white. From reading the Load-Tiles script it looks like GIMP is told to make an image without Alpha, but an Alpha channel seems to get added somewhere along the way, even when only one tile is imported.

I can convert to Indexed Colour at the end with this code, but I haven't yet worked out how to remove the Alpha channel, and it wont let me save until I do that.
gimp.pdb.gimp_convert_indexed (image,0,4,0,0,1,"Scheme250")

This doesn't work:
gimp.pdb.gimp_image_remove_channel (image,"Alpha")


Top
 Post subject: Re: Assembling tiles based on co-ordinates in the file name.
PostPosted: Tue Sep 02, 2014 4:49 pm  (#26) 
Offline
Script Coder
User avatar

Joined: Apr 23, 2010
Posts: 1553
Location: not from Guildford after all
Lumo wrote:
Would it be more efficient to do the tile assembly in Indexed Colour mode instead of converting at the end?
Yes.

Lumo wrote:
I'm also removing the Alpha Channel and replacing it with white. From reading the Load-Tiles script it looks like GIMP is told to make an image without Alpha, but an Alpha channel seems to get added somewhere along the way, even when only one tile is imported.
GIMP will add an alpha channel to the image whenever there is more than one layer, even if none of the layers has an channel.

Lumo wrote:
I can convert to Indexed Colour at the end with this code, but I haven't yet worked out how to remove the Alpha channel, and it wont let me save until I do that.
When executing non-interactive batch code, it is necessary that the image format is compatible with the file format -- it would not make sense to pop up a dialog asking the user what to do.
Lumo wrote:
This doesn't work:
gimp.pdb.gimp_image_remove_channel (image,"Alpha")

There is no such PDB procedure; there is a procedure to remove the alpha channel from a layer, but not from an image. Also, as stated above, an alpha channel is mandated when there is more than one layer in an image.

_________________
Any sufficiently primitive technology is indistinguishable from a rock.


Top
 Post subject: Re: Assembling tiles based on co-ordinates in the file name.
PostPosted: Tue Sep 02, 2014 5:28 pm  (#27) 
Offline
Script Coder
User avatar

Joined: Oct 25, 2010
Posts: 4812
saulgoode wrote:
Lumo wrote:
Would it be more efficient to do the tile assembly in Indexed Colour mode instead of converting at the end?
Yes.


But you run the risk to get jaggy lines, because the first image will dictate the color map for all others, which will likely lose all the colors used in anti-aliasing pixels. Or you specify your own colormap, possibly obtained from an image that contains a good sampling of the tiles.

_________________
Image


Top
 Post subject: Re: Assembling tiles based on co-ordinates in the file name.
PostPosted: Tue Sep 02, 2014 7:19 pm  (#28) 
Offline
Script Coder
User avatar

Joined: Apr 23, 2010
Posts: 1553
Location: not from Guildford after all
ofnuts wrote:
But you run the risk to get jaggy lines, because the first image will dictate the color map for all others, ...

But if lumo's using a custom palette, that should be what dictates the color map. At least that's what I'd expect -- I haven't actually tried it.

_________________
Any sufficiently primitive technology is indistinguishable from a rock.


Top
 Post subject: Re: Assembling tiles based on co-ordinates in the file name.
PostPosted: Thu Sep 04, 2014 3:29 pm  (#29) 
Offline
GimpChat Member

Joined: Jul 19, 2014
Posts: 31
Yeah the tiles are all Indexed Colour to start with and the palette is fixed. Pay attention ;-)

Let's say I start the script with an RGB_IMAGE, then I convert the blank image to INDEXED with my palette (because I have the functions to do that already), then I let it import the tiles. This routine still leaves me with no way to delete the Alpha channel, even though there's only one layer at the end anyway. What can I do to get the INDEXED image without alpha, and ideally save some system resources by working in Indexed from the start?

I can't test anything out right now because the script is running a job and will be for a few more hours. Once this is solved though I believe I can do the rest of the task with a shell script (and a few easy mods).


Top
 Post subject: Re: Assembling tiles based on co-ordinates in the file name.
PostPosted: Fri Sep 05, 2014 12:29 am  (#30) 
Offline
Script Coder
User avatar

Joined: Apr 23, 2010
Posts: 1553
Location: not from Guildford after all
Lumo wrote:
This routine still leaves me with no way to delete the Alpha channel, even though there's only one layer at the end anyway.

You "delete" the alpha channel on an image by flattening it ('gimp-image-flatten').

_________________
Any sufficiently primitive technology is indistinguishable from a rock.


Top
 Post subject: Re: Assembling tiles based on co-ordinates in the file name.
PostPosted: Fri Sep 05, 2014 2:37 pm  (#31) 
Offline
GimpChat Member

Joined: Jul 19, 2014
Posts: 31
Ah! Great. Everything's working now. The transparent pixels take the background colour which is ideal.


Top
Post new topic Reply to topic  [ 31 posts ]  Go to page Previous  1, 2

All times are UTC - 5 hours [ DST ]



* Login  



Powered by phpBB3 © phpBB Group