-
Bug
-
Resolution: Unresolved
-
P4
-
None
-
5.0
-
sparc
-
solaris_10
FULL PRODUCT VERSION :
java version "1.5.0_11"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_11-b03)
Java HotSpot(TM) Server VM (build 1.5.0_11-b03, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
SunOS dove 5.10 Generic_118833-36 sun4u sparc SUNW,Sun-Blade-2500
A DESCRIPTION OF THE PROBLEM :
When saving a BufferedImage as a gif file using the ImageIO.wite call a 0 sized file is produced and the call returns a false. The API reports a false return as there being no supported writer for the format, but ImageIO.getWriterFormatNames reports GIF as a valid format. Works properly under Solaris 9.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run the attached program.
java GIFWriteTest <input file> <output file>
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The input image should be read in and copied to the output file name as a gif image.
ACTUAL -
ImageIO.write is returning a false and producing a 0 size file.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.awt.Graphics;
import java.awt.Toolkit;
import java.awt.image.BufferedImage;
import java.io.File;
import javax.imageio.ImageIO;
import javax.swing.ImageIcon;
public class GIFWriteTest
{
public static void main(String[] args)
{
try {
String source = args[0];
String output = args[1];
ImageIcon ic = new ImageIcon(Toolkit.getDefaultToolkit().createImage(source));
// create the image
BufferedImage img = new BufferedImage(ic.getIconWidth(),
ic.getIconHeight(), BufferedImage.TYPE_INT_ARGB);
Graphics g = img.getGraphics();
g.drawImage(ic.getImage(), 0, 0, null);
String[] formats = ImageIO.getWriterFormatNames();
for (int ii = 0; ii < formats.length; ii++)
{
System.out.println("format: " + formats[ii]);
}
boolean b = ImageIO.write(img, "gif", new File(output));
System.out.println("result: " + b);
}
catch (Exception ex)
{
ex.printStackTrace();
}
}
}
---------- END SOURCE ----------
Support for writting in the particular format does not mean
that any image can be encoded in this format.
This is checked internally and if particular writer can not encode
this particular image then writer will return false.
However, this is not well documented in the description of ImageIO.write.
Perhaps sentence about "appropriate" writer can be clarified.
java version "1.5.0_11"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_11-b03)
Java HotSpot(TM) Server VM (build 1.5.0_11-b03, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
SunOS dove 5.10 Generic_118833-36 sun4u sparc SUNW,Sun-Blade-2500
A DESCRIPTION OF THE PROBLEM :
When saving a BufferedImage as a gif file using the ImageIO.wite call a 0 sized file is produced and the call returns a false. The API reports a false return as there being no supported writer for the format, but ImageIO.getWriterFormatNames reports GIF as a valid format. Works properly under Solaris 9.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run the attached program.
java GIFWriteTest <input file> <output file>
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The input image should be read in and copied to the output file name as a gif image.
ACTUAL -
ImageIO.write is returning a false and producing a 0 size file.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.awt.Graphics;
import java.awt.Toolkit;
import java.awt.image.BufferedImage;
import java.io.File;
import javax.imageio.ImageIO;
import javax.swing.ImageIcon;
public class GIFWriteTest
{
public static void main(String[] args)
{
try {
String source = args[0];
String output = args[1];
ImageIcon ic = new ImageIcon(Toolkit.getDefaultToolkit().createImage(source));
// create the image
BufferedImage img = new BufferedImage(ic.getIconWidth(),
ic.getIconHeight(), BufferedImage.TYPE_INT_ARGB);
Graphics g = img.getGraphics();
g.drawImage(ic.getImage(), 0, 0, null);
String[] formats = ImageIO.getWriterFormatNames();
for (int ii = 0; ii < formats.length; ii++)
{
System.out.println("format: " + formats[ii]);
}
boolean b = ImageIO.write(img, "gif", new File(output));
System.out.println("result: " + b);
}
catch (Exception ex)
{
ex.printStackTrace();
}
}
}
---------- END SOURCE ----------
Support for writting in the particular format does not mean
that any image can be encoded in this format.
This is checked internally and if particular writer can not encode
this particular image then writer will return false.
However, this is not well documented in the description of ImageIO.write.
Perhaps sentence about "appropriate" writer can be clarified.
- relates to
-
JDK-6438508 ImageIO.write() creates an empty file even when the given format is not supported by ImageIO
-
- Closed
-