Raman,

I created a ticket for this issue: 
https://issues.apache.org/jira/browse/NIFI-5355.

I read through the links you provided, thanks for researching the problem so 
thoroughly.
Found some others as well, such as 
https://stackoverflow.com/questions/4391814/why-would-java-awt-image-bufferedimagegettype-return-different-value-mac-cent.

In short, I think this will require a code change, or an OS change 😊. From what 
I’ve read it works on some OS’s but not others, depending on your Java 
implementation on that OS.

Also, in reading up on this, using the method NiFi is using, getScaledInstance, 
apparently isn’t the best option anyways; there appear to be fater/higher 
quality options out there, as outlined here: 
https://stackoverflow.com/a/19507160/328968

So if changes were going to be made, it could conceivably cover both.

Thanks,
  Peter

From: Ramaninder Singh Jhajj [mailto:jhajj.raman...@gmail.com]
Sent: Friday, June 29, 2018 12:12 PM
To: users@nifi.apache.org
Subject: [EXT] Issue with ResizeImage processor for PNG files

Hello Everyone,

I am facing another issue. I am fetching some images from source and store them 
to destination and just before destination processor I have ResizeImage 
Processor.

Now my images can be JPEG or PNG. Processor documentation mentioned that it can 
handle both but it is failing for PNG files with the following error:


ResizeImage[id=2b2bf869-0dcb-351d-857b-bbeef6f27fcf] 
ResizeImage[id=2b2bf869-0dcb-351d-857b-bbeef6f27fcf] failed to process due to 
java.lang.IllegalArgumentException: Unknown image type 0; rolling back session: 
Unknown image type 0

I did some digging and it seems like the issue is with ImageIO library being 
used for resizing.
https://github.com/apache/nifi/blob/master/nifi-nar-bundles/nifi-media-bundle/nifi-media-processors/src/main/java/org/apache/nifi/processors/image/ResizeImage.java#L177

As per this thread "image.getType()" method is the one which creates problem.
https://www.thecodingforums.com/threads/imageio-have-problem-of-reading-png.141174/

https://stackoverflow.com/questions/5836128/how-do-i-make-javas-imagebuffer-to-read-a-png-file-correctly

So seems like for PNG files image.getType returns 0 but it is expecting 5.

Is there any workaround for this without changing the code?

If there is none, I can fix the code and use (can also submit a pull request 
with the fix but I am not sure how to do that.)

Kind Regards,
Raman


Reply via email to