Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
ofn-tiles & ofn-export-layers
#11
Updated the top post and the thread title to include ofn-export-layers.
Reply
#12
Hi, I placed the .py file in the plugin folder under Appdata > Roaming > GIMP >2.~. But I do not see any option under " Layer > Save as Tiles "

Edit : checked the HTML file, it has instructions.
Reply
#13
Which .py?

The HTML file for ofn-tiles:

   

So why are you looking in the Layer menu?
Reply
#14
@Ofnuts The first post said

Quote:ofn-tiles in accessed via Layer>Save as tiles.
Reply
#15
1) Thanks for the script. 


2) For my own uses I made a modification that may help someone else. 

(adding detailed description to aid in search indexing, this is a sorta niche case)

Details:

I'm wanting to slice a bunch of images into tiles for a Minecraft repeating texture (connected texture, method=repeat). The format for this is numbering each tile starting at 0 and incrementing (height and width of the completed tile are defined in the .properties file) with nothing else in the filename. 

Ie, if slicing an image into 4 tiles (2 x ), the files would be: 0.png, 1.png, 2.png, 3.png

To do that I added a formatValue for "current". 

In the version of 'ofn-tiles' dated 2020-08-16, go to line 88, which (in case future updates change the line this occurs on) will look like:
 

Code:
            formatValues['tileRC1']=tileRC+1,


Add a new line below it that says:


Code:
            formatValues['current']=((row*columns)+(column+1))-1

Then when exporting tiles, change the filename to be only:

{current}.png

This addition won't change any other functionality of the script. 

(first time messing with Python, so if I've goofed post a correction Smile

...

Note: if you're here for this and you're ONLY going to be using the plugin for this purposed, you can also change:


Code:
        (PF_STRING,     'namePattern',  'Tile name',   '{imageName}-{column1:02d}-{row1:02d}.png'),


to:

Code:
#        (PF_STRING,     'namePattern',  'Tile name',   '{imageName}-{column1:02d}-{row1:02d}.png'),
        (PF_STRING,     'namePattern',  'Tile name',   '{current}.png'),

and it will default to this as the export filename (for the rows and columns method, changing the width and height default is equally as easy).
Reply
#16
(12-15-2021, 04:34 AM)jahf Wrote: 1) Thanks for the script. 


2) For my own uses I made a modification that may help someone else.

No need to change the script, this is what the tileRC0, tileCR0,tileRC1, tileCR1 are supposed to do:

Quote: tileCR0, tileCR1, tileRC0, tileRC1: the sequence number of the tile. The tileRC value increments the columns before the rows, and the tileCR values increments the rows before the columns.

So starting with this:

   

For tileRC0 you get this:

   



Which is what you want, or am I missing something?
Reply
#17
(12-15-2021, 07:43 AM)Ofnuts Wrote:
Quote: tileCR0, tileCR1, tileRC0, tileRC1: the sequence number of the tile. The tileRC value increments the columns before the rows, and the tileCR values increments the rows before the columns.

I'm sorry if I'm wrong, my English is admittedly deplorable, but wouldn't it be the other way around?

The tileRC value increments the rows before the columns, and the tileCR values increments the columns before the rows. ?! Huh
                               .....
Samj PortableGimp 2.10.28 - Win-10 /64.
Reply
#18
(12-15-2021, 01:27 PM)Krikor Wrote:
(12-15-2021, 07:43 AM)Ofnuts Wrote:
Quote: tileCR0, tileCR1, tileRC0, tileRC1: the sequence number of the tile. The tileRC value increments the columns before the rows, and the tileCR values increments the rows before the columns.

I'm sorry if I'm wrong, my English is admittedly deplorable, but wouldn't it be the other way around?

The tileRC value increments the rows before the columns, and the tileCR values increments the columns before the rows. ?! Huh

No, that's the way it is. The coordinates of the tiles in a X,Y referential is really (column,row). So tileRC, to ouput the images row by row, goes (1, 1), (2, 1), (1, 2), (2, 2) and this increments the columns before the rows:

   
Reply
#19
It took me a while to understand this.

The explanation given in the previous post was excellent and clarified my doubts!

"The coordinates of the tiles in a referential X,Y is really (column,row). So tileRC, to output the images row by row, goes (1, 1), (2, 1), (1, 2), (2, 2) and this increments the columns before the rows"

My question was about:

"the sequence number of the tile. The tileRC value increments the columns before the rows, and the tileCR value increments the rows before the columns."

Why did I think the sequence was reversed? Because the way I was looking at the process was different!

In the case of TileRC, I thought that the tiles from the first row were selected first, then those from the second row, etc. until the last row.
In the example in the image below, the order obtained from the Tiles is:
a1, b1, c1,d1 and e1 (first row), then a2, b2, ...,e2 (second row), etc.

[Image: PeDtOou.png]
In the case of TileCR, as shown in the image below, first the tiles in the first column were selected, then those in the second column, etc.
a1, a2, a3, a4 (first column); b1, b2, b3, b4 (second column), etc.

[Image: VmxjjFh.png]
Hence my doubt.

Perhaps a matter of point of view (not regarding the process itself, as explained in the previous post):

In the TileRC of the image below, to output the images row by row, goes:
[Image: attachment.php?aid=7242]
01- (1, 1), (2, 1), (1, 2), (2, 2) and this increments the columns before the rows.
02- As I see it: Take everything on the first line, then everything on the second line, etc.

[Image: J3TZkhm.png]
For TileCR, goes:

[Image: HloG4vs.png]
01- (1,1), (1,2), 2,1), (2,2) and this increments the rows before the columns.
02- As I see it: Take the entire first column, then the second column, etc.

[Image: AbjQL0P.png]
A half full glass of water, was it half full or half empty?
                               .....
Samj PortableGimp 2.10.28 - Win-10 /64.
Reply
#20
Photo 
(08-09-2017, 09:15 PM)Ofnuts Wrote: The place to discuss ofn-tiles (still fairly experimental as this thread is started) and ofn-export-layers

ofn-tiles and ofn-export-layers are available here (as separate packages).

So, you have a layer, ofn-tiles will cut it into X by Y tiles (you give the number of tiles of each direction), and save each tile in a
specified directory. ofn-tiles in accessed via Layer>Save as tiles.

Name of the tiles: the file names of the tiles are obtained by inserting the row and column number of the tile (or its sequence number) in a string that your provide. The place where these numbers are inserted are indicated by names in braces:
  • row0, row1 is the row number of the tile. When using "row0" the first row is 0 and when using "row1" the first row is 1.
  • column0, column1 is the column number of the tile. Ending in 0,1 is same as above
  • tileRC0,tileRC1, tileCR0,tileCR1,  is the tile number. Ending in 0,1 is same as above. The *CR has the rows scanned first so tiles 1, 2, 3 are in the first column while the *RC has the columns scanned first, and tiles 1,2,3 are in the first row.
  • the string is the complete name of the file and should have an image format extension (png, gif, jpg...) since it will be used by Gimp to determine how to save the file. The defaults settings for the file type are used.
  • the name pattern is actually a Python format, so modifiers can be used. For instance {row0:03d} will insert the row number on at least three digits, with zeroes added to the left if necessary: "000", "001", "013", "099", "100" 
ofn-export-layers is a close cousin, it exports all the layers of the image as separate files, using the same flexible way of naming the output files.

When I use ofn-tiles it exports empty tiles as black tiles and I do not want that.
I want it to export all the tiles which have something drawn on them, please help me. I do not want empty blank black tiles, I want only the ones which have something on them. 
I do not know how to write a script to check if the tile has something on it and then export.
Can someone show me how to export only the tiles which are not empty with ofn-tiles? 


Attached Files Thumbnail(s)
   
Reply


Forum Jump: