Merge pull request #1819 from OffenesFELD/master

Fixes processing/processing#1810 where a png data would be written instead of jpeg data.
This commit is contained in:
Ben Fry
2013-05-30 12:54:53 -07:00

View File

@@ -3132,6 +3132,7 @@ public class PImage implements PConstants, Cloneable {
ImageWriter writer = null;
ImageWriteParam param = null;
IIOMetadata metadata = null;
if (extension.equals("jpg") || extension.equals("jpeg")) {
if ((writer = imageioWriter("jpeg")) != null) {
// Set JPEG quality to 90% with baseline optimization. Setting this
@@ -3143,12 +3144,16 @@ public class PImage implements PConstants, Cloneable {
param.setCompressionQuality(0.9f);
}
}
if ((writer = imageioWriter("png")) != null) {
param = writer.getDefaultWriteParam();
if (false) {
metadata = imageioDPI(writer, param, 100);
if (extension.equals("png")) {
if ((writer = imageioWriter("png")) != null) {
param = writer.getDefaultWriteParam();
if (false) {
metadata = imageioDPI(writer, param, 100);
}
}
}
if (writer != null) {
BufferedOutputStream output =
new BufferedOutputStream(PApplet.createOutput(file));