Skip to content

Commit 5a81363

Browse files
committed
Merge pull request processing#1819 from OffenesFELD/master
Fixes processing#1810 where a png data would be written instead of jpeg data.
2 parents 453a34e + 6be1b1b commit 5a81363

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

core/src/processing/core/PImage.java

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3132,6 +3132,7 @@ protected boolean saveImageIO(String path) throws IOException {
31323132
ImageWriter writer = null;
31333133
ImageWriteParam param = null;
31343134
IIOMetadata metadata = null;
3135+
31353136
if (extension.equals("jpg") || extension.equals("jpeg")) {
31363137
if ((writer = imageioWriter("jpeg")) != null) {
31373138
// Set JPEG quality to 90% with baseline optimization. Setting this
@@ -3143,12 +3144,16 @@ protected boolean saveImageIO(String path) throws IOException {
31433144
param.setCompressionQuality(0.9f);
31443145
}
31453146
}
3146-
if ((writer = imageioWriter("png")) != null) {
3147-
param = writer.getDefaultWriteParam();
3148-
if (false) {
3149-
metadata = imageioDPI(writer, param, 100);
3147+
3148+
if (extension.equals("png")) {
3149+
if ((writer = imageioWriter("png")) != null) {
3150+
param = writer.getDefaultWriteParam();
3151+
if (false) {
3152+
metadata = imageioDPI(writer, param, 100);
3153+
}
31503154
}
31513155
}
3156+
31523157
if (writer != null) {
31533158
BufferedOutputStream output =
31543159
new BufferedOutputStream(PApplet.createOutput(file));

0 commit comments

Comments
 (0)