Question

Converting PDFs to JPGs

  • 21 February 2024
  • 7 replies
  • 60 views

Badge +5

Hello,

I continue to have trouble converting PDFs to JPGs!  I am/have been followed the instruction on:

but keep getting errors on the Writer. 

JPEG writer: This format cannot support more than 3 bands.  Please remove the extra bands and try again
JPEG writer: An error has occurred. Check the logfile above for details

 

How do I find out the number of Bands as they pertain to ImageRasterizer’s Raster Properties Number of Columns and Number of Rows??  Or is there another way??

 

Thx

Brian


7 replies

Userlevel 3
Badge +17

Hello @klingdom,

Based on the error you’re seeing, the rasterized output from the PDF reader is RGBA32, which the JPEG writer cannot handle as this format does not support alpha bands.

Use a RasterInterpretationCoercer and set the Destination Interpretation Type parameter to “RGB24”, and choose to either apply or drop the alpha band in the RGBA to RGB parameter.

I hope this helps.

Userlevel 5
Badge +30

Hello @klingdom,

Based on the error you’re seeing, the rasterized output from the PDF reader is RGBA32, which the JPEG writer cannot handle as this format does not support alpha bands.

Use a RasterInterpretationCoercer and set the Destination Interpretation Type parameter to “RGB24”, and choose to either apply or drop the alpha band in the RGBA to RGB parameter.

I hope this helps.

Great @debbiatsafe 

Badge +5

debbiatsafe,

 

I tried your instruction and many gyrations, but still getting Errors @ReinterpretRaster: Failed to obtain raster from feature.  Only features with raster geometry are expected.

Is there a GEOMETRY_TYPE that needs to be expose?

I’m pretty sure these are PDF exports from A-CAD.  I attached a zip of the log and PDF

Thx

Brian

Userlevel 3
Badge +17

Hi @klingdom 

Based on the error in the log, you are attempting to send vector features into the RasterInterpretationCoercer transformer. Rasterized pages are output from the pdf_rasterized_pages feature type while vector features are output from the pdf_no_layer feature type.

Re-add a PDF reader that has the Read Rasterized Page parameter enabled (in Non-Spatial section) and connect pdf_rasterized_pages feature type to the RasterInterpretationCoercer.

The PDF file you sent has a rotation applied so you may need to rotate the raster before writing to JPEG. Alternatively, you can also generate a world file in the JPEG writer to auto-apply the rotation. The output JPEG file will then appear in the expected page orientation.

Badge +5

debbiatsafe,

 

Thx very much for all your help!  I have now got the transformation to run without errors.  How can I flip the background and foreground  to black lines on white?

Is there any reading and training on this?

Thx

Brian

 

 

Userlevel 3
Badge +17

Hi @klingdom,

Change the RasterInterpretationCoercer’s RGBA to RGB parameter from the default “Drop alpha band” value to “Apply alpha band” for a white background.

Badge +5

Hey debbiatsafe,

That worked!

Darn!  I thought I had tried that just to see what would happen.  

Many Thanks for your help!

 

Reply