Solved

PNG Optimization


Badge

I'm creating a SQLite Tilecache via the WebMapTiler, with PNG blobs, and would like to use PNG Optimization. This seems to be available in the PNGRaster writer, but I'm not using the PNGraster writer, I'm using the SQLite writer. So, is there any way I can pull that piece of code or is there another transformer I could use to do the same job of PNG Optimization?

icon

Best answer by daveatsafe 31 May 2018, 18:47

View original

5 replies

Badge +16

Hi @erinjayaustin,

It might no be the most straight forward method, but you could write the rasters with the PNG writer via the FeatureWriter read them (FeatureReader) and write to the DB.

Hope this helps.

Userlevel 2
Badge +17

Hi @erinjayaustin,

If you are using the RasterExtractor to create the PNG blobs for SQLite, you can replace it with a combination of a FeatureWriter (to write out a PNG) and an AttributeFileReader (to read the PNG back into a blob attribute). This will allow you to control the optimization of the PNG files.

To avoid creating a lot of PNG files on your drive, you can reuse the same name for all the tiles (ie. temp.png). You can also use the TempPathnameCreator to create a temporary folder for your PNGs that will be automatically cleaned up when the workspace finishes.

This is essentially the same process the RasterExtractor uses, so it shouldn't affect the workspace performance at all.

Badge

Hi @erinjayaustin,

If you are using the RasterExtractor to create the PNG blobs for SQLite, you can replace it with a combination of a FeatureWriter (to write out a PNG) and an AttributeFileReader (to read the PNG back into a blob attribute). This will allow you to control the optimization of the PNG files.

To avoid creating a lot of PNG files on your drive, you can reuse the same name for all the tiles (ie. temp.png). You can also use the TempPathnameCreator to create a temporary folder for your PNGs that will be automatically cleaned up when the workspace finishes.

This is essentially the same process the RasterExtractor uses, so it shouldn't affect the workspace performance at all.

Hi @DaveAtSafe, thank you. This makes sense.

 

 

I have added the FeatureWriter & AttributeFileReader to the workspace, and used your advice with adding the TempPathnameCreator, but the AttributeFileReader is waiting for all the features to be written before reading anything, rather than reading them in as they are created. Any idea what I am doing wrong?

 

 

Workspace:

Userlevel 2
Badge +17
Hi @DaveAtSafe, thank you. This makes sense.

 

 

I have added the FeatureWriter & AttributeFileReader to the workspace, and used your advice with adding the TempPathnameCreator, but the AttributeFileReader is waiting for all the features to be written before reading anything, rather than reading them in as they are created. Any idea what I am doing wrong?

 

 

Workspace:

Hi @erinjayaustin,

 

In the FeatureWriter, please set the Output Ports to One per Feature Type. This will add a second output port through which each raster can be output to the AttributeFileReader. The Summary output gives only a single feature for each run.

 

Badge
Hi @erinjayaustin,

 

In the FeatureWriter, please set the Output Ports to One per Feature Type. This will add a second output port through which each raster can be output to the AttributeFileReader. The Summary output gives only a single feature for each run.

 

Hi @DaveAtSafe, thanks for getting back to me. I've installed FME 2018 as I think those FeatureWriter options were introduced in FME 2017, and it seems to be working! I really appreciate your advice & help. Thank you.

 

Reply