Skip to main content
Solved

PNG Optimization


Forum|alt.badge.img

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?

Best answer by daveatsafe

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.

View original
Did this help you find an answer to your question?

5 replies

itay
Supporter
Forum|alt.badge.img+16
  • Supporter
  • May 31, 2018

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.


daveatsafe
Safer
Forum|alt.badge.img+19
  • Safer
  • Best Answer
  • May 31, 2018

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.


Forum|alt.badge.img
daveatsafe wrote:

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:


daveatsafe
Safer
Forum|alt.badge.img+19
  • Safer
  • June 1, 2018
erinjayaustin wrote:
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.

 


Forum|alt.badge.img
daveatsafe wrote:
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


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings