-1

I need something other than ImageIO to read in a jpeg and put into a BufferedImage object. There are issues with getting ImageIO to work in servlets. I am working with the ImageIO developers but so far no luck and it may never work on the server side. I am using Wildfly app server. So I need a backup for Java for ImageIO that will read in a jpeg and transfer to a BufferedImage. Any recommendations?

Tony Anecito
  • 347
  • 2
  • 13
  • 3
    ImageIO works perfectly. – Boann Jun 27 '17 at 17:59
  • Sure on client side not in a server. Classloader issues. – Tony Anecito Jun 27 '17 at 18:00
  • 2
    have a look at https://github.com/dragon66/icafe – cello Jun 27 '17 at 18:13
  • 1
    What exception do you get (so we can be sure you have THE issue we assume)? By default many image operations relay on the undelaying system libraries (AWT) so without graphical libraries (X Windows) the operations may/will fail. You need to have some lighter replacement (already mentioned icafe). Search for 'headless' jvm (e.g. http://www.oracle.com/technetwork/articles/javase/headless-136834.html) – gusto2 Jun 27 '17 at 18:29
  • Ok here is the link to the issue and the error messages. https://github.com/haraldk/TwelveMonkeys/issues/357 The issue really is a known one for ImageIO and app servers. It has nothing to do with the AWT. Developers are using ImageIO and plugins and may need to consider if classloaders are involved. – Tony Anecito Jun 27 '17 at 18:57
  • Be really interesting if Java 9 causes even more issues for ImageIO. Bottom line is do not design using classloaders if you want to support server side apps/services. Which means most everything. – Tony Anecito Jun 27 '17 at 19:05
  • 2
    Indeed, that's THE issue. You may try to use a "non-awt" toolkit (icafe, PJAToolkit) or you could just indicate the JVM is "headless" ( -Djava.awt.headless=true ) but you should indeed test it – gusto2 Jun 27 '17 at 19:09
  • Thanks. I was delaying trying to give the developers a chance. But I totally agree with everything you said. I am reading images on the server side and want to not use something relying on the AWT if that is what is going on at a lower level. Simple is better and what I want to do should not mean adding so many other classes for two lines of code. – Tony Anecito Jun 27 '17 at 19:19

2 Answers2

1

As recommended by others I will use iCafe or something like it for reading a jpeg on the server side. Imageio is really meant for client side despite the articles I have seen after googling. Thanks All I really appreciated your responses!

Tony Anecito
  • 347
  • 2
  • 13
  • 1
    I ended up solving the problem. Not sure why ImageIO wanted twelvemonkeys plugin but I got that to work after adding the correct libraries to my war, adding a listener to my .web file and registering several providers related to twelvemonkeys. – Tony Anecito Jul 03 '17 at 18:54
-1

I think you need to construct the image and use it without depending on java image api. Also to construct and reproduce the same image data, you might need to do the image sampling.

http://www.developer.com/java/other/article.php/3403921/Processing-Image-Pixels-using-Java-Getting-Started.htm