Skip to content

Commit

Permalink
Version 1.3.4
Browse files Browse the repository at this point in the history
Update dependencies and optimize image processing

Removed imgscalr-lib and added simple-png-javafx as a dependency to enhance image processing and remove dependency on AWT and Swing. Optimized the image resizing process in 'ProcessFile' by reusing the last resized image when the next image size is the same as the last one. Unnecessary print statements were removed, and project version was updated to 1.3.4.
  • Loading branch information
EasyG0ing1 committed Dec 15, 2023
1 parent a13776e commit 10d352c
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 14 deletions.
12 changes: 6 additions & 6 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>com.simtechdata</groupId>
<artifactId>MacIcns</artifactId>
<version>1.3.3</version>
<version>1.3.4</version>
<packaging>jar</packaging>

<properties>
Expand Down Expand Up @@ -42,16 +42,16 @@
<artifactId>javafx-swing</artifactId>
<version>${javafx.version}</version>
</dependency>
<dependency>
<groupId>org.imgscalr</groupId>
<artifactId>imgscalr-lib</artifactId>
<version>4.2</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.15.1</version>
</dependency>
<dependency>
<groupId>org.glavo</groupId>
<artifactId>simple-png-javafx</artifactId>
<version>0.2.0</version>
</dependency>
<dependency>
<groupId>com.simtechdata</groupId>
<artifactId>JavaProc</artifactId>
Expand Down
25 changes: 20 additions & 5 deletions src/main/java/com/simtechdata/ProcessFile.java
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
package com.simtechdata;

import javafx.embed.swing.SwingFXUtils;
import javafx.scene.image.Image;
import javafx.scene.image.WritableImage;
import javafx.scene.paint.Color;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.FilenameUtils;
import org.glavo.png.javafx.PNGJavaFXUtils;

import javax.imageio.ImageIO;
import java.io.File;
import java.io.IOException;
import java.nio.file.Path;
Expand Down Expand Up @@ -133,22 +132,38 @@ public Job(Image original, Path path, int size) {
this.size = size;
}

public static WritableImage lastImage;
private final Image original;
private final Path path;
private final int size;
private int lastSize = 0;

public void saveFile() {
try {
WritableImage finalImage = getImage();
ImageIO.write(SwingFXUtils.fromFXImage(finalImage, null), "PNG", path.toFile());
PNGJavaFXUtils.writeImage(getImage(), path);
} catch (IOException e) {
throw new RuntimeException(e);
}
}

private WritableImage getImage() {
try {
return resizeImage(original, size, size);
WritableImage writableImage;
if(lastImage == null) {
writableImage = resizeImage(original, size, size);
lastImage = writableImage;
lastSize = size;
}
else {
if(size == lastSize) {
writableImage = lastImage;
}
else {
writableImage = resizeImage(lastImage, size, size);
lastSize = size;
}
}
return writableImage;
} catch (Exception e) {
throw new RuntimeException(e);
}
Expand Down
1 change: 0 additions & 1 deletion src/main/java/com/simtechdata/Run.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ public int run() {
.withNoTimeout()
.ignoreExitStatus()
.run();
System.out.println(result.getCommandLine());
return result.getExitValue();
}
}
1 change: 0 additions & 1 deletion src/main/java/com/simtechdata/utils/Shell.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ public static int run(String command, String[] args) {
.withNoTimeout()
.ignoreExitStatus()
.run();
System.out.println(r.getCommandLine());
return r.getExitValue();
}
}
2 changes: 1 addition & 1 deletion src/main/java/module-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
requires javafx.swing;
requires java.desktop;
requires org.apache.commons.io;
requires imgscalr.lib;
requires org.glavo.png.javafx;
requires java.prefs;
requires JavaProc;

Expand Down

0 comments on commit 10d352c

Please sign in to comment.