<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<id>tag:www.nabble.com,2006:forum-13399</id>
	<title>Nabble - Sun - Java-Imageio-Interest</title>
	<updated>2008-03-31T16:02:46Z</updated>
	<link rel="self" type="application/atom+xml" href="http://www.nabble.com/Sun---Java-Imageio-Interest-f13399.xml" />
	<link rel="alternate" type="text/html" href="http://www.nabble.com/Sun---Java-Imageio-Interest-f13399.html" />
	<subtitle type="html">Discussion list for Java Image I/O API</subtitle>
	
<entry>
	<id>tag:www.nabble.com,2006:post-16411291</id>
	<title>Saving image along with metadata changes white to red</title>
	<published>2008-03-31T16:02:46Z</published>
	<updated>2008-03-31T16:02:46Z</updated>
	<author>
		<name>Carl Antaki</name>
	</author>
	<content type="html">Hi everybody,&lt;br&gt;&lt;br&gt;&lt;br&gt; In my image resize/compress code I&amp;#39;m trying to save an image along
with its Exif metadata but for some images the image becomes red. I&amp;#39;m
using com.sun.imageio.plugins.jpeg.JPEGImageReader and
com.sun.imageio.plugins.jpeg.JPEGImageWriter. The image type is &lt;pre&gt;TYPE_3BYTE_BGR&lt;br&gt;&lt;/pre&gt; &lt;br&gt;&lt;br&gt;getMetaData() seems to be the culprit because if I put null instead it works.&lt;br&gt;Here is an excerpt of my code:&lt;br&gt;&lt;pre&gt;
 IIOImage destIIOImage = &lt;font color=&quot;navy&quot;&gt;&lt;b&gt;new&lt;/b&gt;&lt;/font&gt; IIOImage(thumbImage, null, srcIIOImage.getMetadata());&lt;br&gt;        BufferedOutputStream out;&lt;br&gt;        ImageWriter writer = &lt;font color=&quot;navy&quot;&gt;&lt;b&gt;null&lt;/b&gt;&lt;/font&gt;;&lt;br&gt;

        ImageOutputStream imgout = &lt;font color=&quot;navy&quot;&gt;&lt;b&gt;null&lt;/b&gt;&lt;/font&gt;;&lt;br&gt;        FileOutputStream fos =&lt;font color=&quot;navy&quot;&gt;&lt;b&gt;null&lt;/b&gt;&lt;/font&gt;;&lt;br&gt;        &lt;font color=&quot;navy&quot;&gt;&lt;b&gt;try&lt;/b&gt;&lt;/font&gt; &lt;font color=&quot;navy&quot;&gt;{&lt;/font&gt;&lt;br&gt;

            fos = &lt;font color=&quot;navy&quot;&gt;&lt;b&gt;new&lt;/b&gt;&lt;/font&gt; FileOutputStream(outFile);&lt;br&gt;            out = &lt;font color=&quot;navy&quot;&gt;&lt;b&gt;new&lt;/b&gt;&lt;/font&gt; BufferedOutputStream(fos);&lt;br&gt; &lt;br&gt;            quality = Math.max(0, Math.min(quality, 100));&lt;br&gt;

            Iterator it = &lt;font color=&quot;navy&quot;&gt;&lt;b&gt;null&lt;/b&gt;&lt;/font&gt;;&lt;br&gt;            &lt;font color=&quot;navy&quot;&gt;&lt;b&gt;if&lt;/b&gt;&lt;/font&gt;(inFile.toUpperCase().endsWith(&lt;font color=&quot;red&quot;&gt;&amp;quot;.JPG&amp;quot;&lt;/font&gt;) || inFile.toUpperCase().endsWith(&lt;font color=&quot;red&quot;&gt;&amp;quot;.JPEG&amp;quot;&lt;/font&gt;))&lt;font color=&quot;navy&quot;&gt;{&lt;/font&gt;&lt;br&gt;

                it = ImageIO.getImageWriters(&lt;font color=&quot;navy&quot;&gt;&lt;b&gt;new&lt;/b&gt;&lt;/font&gt; ImageTypeSpecifier((BufferedImage)image), &lt;font color=&quot;red&quot;&gt;&amp;quot;jpg&amp;quot;&lt;/font&gt;);&lt;br&gt;                &lt;font color=&quot;navy&quot;&gt;&lt;b&gt;if&lt;/b&gt;&lt;/font&gt;(it.hasNext())&lt;font color=&quot;navy&quot;&gt;{&lt;/font&gt;&lt;br&gt;

                    imgout = ImageIO.createImageOutputStream(out);&lt;br&gt;                    writer = (ImageWriter) it.next();&lt;br&gt;                    writer.setOutput(imgout);&lt;br&gt;                    ImageWriteParam param = writer.getDefaultWriteParam();&lt;br&gt;

                    param.setCompressionMode(ImageWriteParam.MODE_EXPLICIT);&lt;br&gt;                    param.setCompressionQuality(quality/100f);&lt;br&gt;&amp;nbsp;&lt;br&gt;&amp;nbsp;&lt;br&gt;                    IIOMetadata meta = writer.getDefaultStreamMetadata(param);&lt;br&gt;

                    &lt;br&gt;                    writer.write(meta, destIIOImage, param);&lt;br&gt;                    image = &lt;font color=&quot;navy&quot;&gt;&lt;b&gt;null&lt;/b&gt;&lt;/font&gt;;&lt;br&gt;                &lt;font color=&quot;navy&quot;&gt;}&lt;/font&gt;&lt;br&gt;            &lt;font color=&quot;navy&quot;&gt;}&lt;/font&gt;
&lt;/pre&gt;&lt;br&gt;Using the simple code everything works fine but I can&amp;#39;t control compression quality:&lt;br&gt;&lt;pre&gt;ImageIO.write(image,&lt;font color=&quot;red&quot;&gt;&amp;quot;jpg&amp;quot;&lt;/font&gt;,file)&lt;br&gt;&lt;/pre&gt;I also tried to use&amp;nbsp; ImageWriteParam param = new JPEGImageWriteParam(Locale.getDefault());&lt;br&gt;

instead of &lt;br&gt;&lt;pre&gt; ImageWriteParam param = writer.getDefaultWriteParam();&lt;br&gt;but that didn&amp;#39;t work either&lt;br&gt;&lt;/pre&gt;
Thanks,&lt;br&gt;&lt;br&gt;Carl Antaki
        
===========================================================================
To unsubscribe, send email to &lt;a href=&quot;http://www.nabble.com/user/SendEmail.jtp?type=post&amp;post=16411291&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;listserv@...&lt;/a&gt; and include in the body
of the message &quot;signoff JAVA-IMAGEIO-INTEREST&quot;.  For general help, send email to
&lt;a href=&quot;http://www.nabble.com/user/SendEmail.jtp?type=post&amp;post=16411291&amp;i=1&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;listserv@...&lt;/a&gt; and include in the body of the message &quot;help&quot;.
</content>
	<link rel="alternate" type="text/html" href="http://www.nabble.com/Saving-image-along-with-metadata-changes-white-to-red-tp16411291p16411291.html" />
</entry>

<entry>
	<id>tag:www.nabble.com,2006:post-14306257</id>
	<title>ImageIO static lookup issues</title>
	<published>2007-12-12T15:11:41Z</published>
	<updated>2007-12-12T15:11:41Z</updated>
	<author>
		<name>Nidel, Mike</name>
	</author>
	<content type="html">&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 3.2//EN&quot;&gt;
&lt;HTML&gt;
&lt;HEAD&gt;
&lt;META HTTP-EQUIV=&quot;Content-Type&quot; CONTENT=&quot;text/html; charset=us-ascii&quot;&gt;
&lt;META NAME=&quot;Generator&quot; CONTENT=&quot;MS Exchange Server version 6.5.7653.2&quot;&gt;
&lt;TITLE&gt;ImageIO static lookup issues&lt;/TITLE&gt;
&lt;/HEAD&gt;
&lt;BODY&gt;
&lt;!-- Converted from text/rtf format --&gt;

&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Courier New&quot;&gt;There has been almost no traffic on this list in 2007, and the last post I made over a year ago never got a reply, so this is a shot in the dark.&lt;/FONT&gt;&lt;/P&gt;

&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Courier New&quot;&gt;The problem that I have seen with ImageIO numerous times in the past 4 years or so is the fact of static lookup and access. It doesn't take a lot of experience with static references to learn that they are both very powerful and very susceptible to problems. Particularly in an environment where multiple independent components share a single VM and memory heap, conflicts in static access can create unexpected behavior and even catastrophic failure. Add in a complex ClassLoader hierarchy, as exists in most J2EE application containers, and the effects are compounded by the difficulty of tracing problems to their source.&lt;/FONT&gt;&lt;/P&gt;

&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Courier New&quot;&gt;The reason this affects ImageIO is as follows: Suppose I have two applications (A and B) that both use a custom ImageIO ImageReader called MyImageReader. If those two apps are run in the same VM -- for instance, under a J2EE app container -- then their two sets of ImageReaders are both statically loaded by the same instance of the ImageIO class. Suppose there is a jar called MyImageReader.jar, located on the classpath of EACH of these apps -- for example, in their EAR file. This generally results in two copies of the MyImageReader class being loaded, because due to the security model of app containers the classes in App A are not visible to App B, by necessity.&lt;/FONT&gt;&lt;/P&gt;

&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Courier New&quot;&gt;So now we've got two instances of the same class, MyImageReader{A} and MyImageReader{B}. Now suppose App A wants to read an image. It calls ImageIO.getImageReaders(inputStream) or a similar API. The ImageIO class, which can access and call both {A} and {B}, interrogates the two reader SPIs and returns an Iterator with an instance of both MyImageReader{A} and MyImageReader{B}. App A, let's say, takes the first reader, which is its &amp;quot;own&amp;quot; instance of MyImageReader{A}, and everything works fine.&lt;/FONT&gt;&lt;/P&gt;

&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Courier New&quot;&gt;Now what happens when App B uses the exact same sequence of calls? It should end up with an instance of MyImageReader{A}, which is inaccessible to it. Therefore some kind of error will occur, depending what the app tries to do with the reader.&lt;/FONT&gt;&lt;/P&gt;
&lt;BR&gt;

&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Courier New&quot;&gt;The fundamental problem here is that an app cannot interrogate the ImageIO class in a way that returns only plugins that are accessible within the calling classloader. Is there some way that you can see to do this? Or is there some kind of check that could be performed so that App B can detect when a plugin it receives is not visible to it and it should discard it as unusable?&lt;/FONT&gt;&lt;/P&gt;

&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Courier New&quot;&gt;There may be some simple workaround that I haven't come up with yet, but it seems to me a problem that should have a more well-engineered solution.&lt;/FONT&gt;&lt;/P&gt;

&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Courier New&quot;&gt;Thanks for any input,&lt;/FONT&gt;
&lt;/P&gt;

&lt;P&gt;&lt;FONT SIZE=2 FACE=&quot;Courier New&quot;&gt;Mike Nidel&lt;/FONT&gt;
&lt;/P&gt;

&lt;/BODY&gt;
&lt;/HTML&gt;
===========================================================================
To unsubscribe, send email to &lt;a href=&quot;http://www.nabble.com/user/SendEmail.jtp?type=post&amp;post=14306257&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;listserv@...&lt;/a&gt; and include in the body
of the message &quot;signoff JAVA-IMAGEIO-INTEREST&quot;.  For general help, send email to
&lt;a href=&quot;http://www.nabble.com/user/SendEmail.jtp?type=post&amp;post=14306257&amp;i=1&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;listserv@...&lt;/a&gt; and include in the body of the message &quot;help&quot;.
</content>
	<link rel="alternate" type="text/html" href="http://www.nabble.com/ImageIO-static-lookup-issues-tp14306257p14306257.html" />
</entry>

<entry>
	<id>tag:www.nabble.com,2006:post-13045000</id>
	<title>Imaging and graphics job opening at Sun.</title>
	<published>2007-10-04T11:37:29Z</published>
	<updated>2007-10-04T11:37:29Z</updated>
	<author>
		<name>Phil Race</name>
	</author>
	<content type="html">Hello all,
&lt;br&gt;&lt;br&gt;The Java 2D graphics and JAI imaging team here at Sun have an immediate
&lt;br&gt;opening for an engineer to join us to work on imaging and graphics
&lt;br&gt;for Java SE.
&lt;br&gt;&lt;br&gt;The full details of the job are posted at the link below where
&lt;br&gt;you may also submit your resumé to apply.
&lt;br&gt;&lt;br&gt;&lt;a href=&quot;http://www.sun.com/corp_emp/search.cgi?funcs=&amp;loc=&amp;keyword=555887&amp;x=&amp;y=&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://www.sun.com/corp_emp/search.cgi?funcs=&amp;loc=&amp;keyword=555887&amp;x=&amp;y=&lt;/a&gt;&lt;br&gt;&lt;br&gt;-Phil Race, Java 2D.
&lt;br&gt;&lt;br&gt;===========================================================================
&lt;br&gt;To unsubscribe, send email to &lt;a href=&quot;http://www.nabble.com/user/SendEmail.jtp?type=post&amp;post=13045000&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;listserv@...&lt;/a&gt; and include in the body
&lt;br&gt;of the message &amp;quot;signoff JAVA-IMAGEIO-INTEREST&amp;quot;. &amp;nbsp;For general help, send email to
&lt;br&gt;&lt;a href=&quot;http://www.nabble.com/user/SendEmail.jtp?type=post&amp;post=13045000&amp;i=1&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;listserv@...&lt;/a&gt; and include in the body of the message &amp;quot;help&amp;quot;.
&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://www.nabble.com/Imaging-and-graphics-job-opening-at-Sun.-tp13045000p13045000.html" />
</entry>

</feed>
