Skip to main content
Question

Trim white borders of PNG result from ChartGenerator

  • 20 January 2021
  • 3 replies
  • 9 views

I'm building an html file with data and charts.

The PNG charts generated with the ChartGenerator transformer have huge white borders around the actual chart and legend and make my html look bad. I want to trim those borders and I'm doing this, but I wonder if it's the best approach:

  • I use a RasterBandNodataSetter to set white colour to Nodata value.
  • With RasterExtentsCoercer adjusted to use DataMBRExtents I get a polygon with the extent without the white borders
  • And with the Clipper I clip the PNG chart with that extent.

 

chart_clip_flowchart_clipI there any other way of doing this? I have 16 charts to add to the html file so I'd prefer to do this same thing with just one or two transformers.

 

3 replies

Badge +11

Does this not work? If it does: (1)Put it in a bookmark and collapse it or (2) create custom transformer

Badge +10

Does this not work? If it does: (1)Put it in a bookmark and collapse it or (2) create custom transformer

It does but I expected to find some kind of 'PixelTrimer' transformer that would let me set the number of pixels to trim on each side. I searched intensively the transformer gallery to no avail and thought it was just my lack of ability to guess its name.

 

But yes, you are right. A custom transformer will do. Thanks!

Badge +11

It does but I expected to find some kind of 'PixelTrimer' transformer that would let me set the number of pixels to trim on each side. I searched intensively the transformer gallery to no avail and thought it was just my lack of ability to guess its name.

 

But yes, you are right. A custom transformer will do. Thanks!

I feel you. I am also looking for an approach to crop png output from imagefetcher transformer. The closest I got was similar to you, but used a creator xfrm as the clipper. The terminology in raster is much more scientific/physics-speak, where as vector can be more layman's terms.

Reply