Sub ConvertImage (InputDir As String, InputFile As String, OutputDir As String, OutputFile As String) As Boolean
Try
If InputFile = "" Or File.Exists(InputDir, InputFile) = False Then
Log("File not found")
Return False
End If
Dim jo As JavaObject = Me
jo.RunMethod("ConvertJpg2Png", Array(File.Combine(InputDir, InputFile), File.Combine(OutputDir, OutputFile)))
Return True
Catch
Log(LastException)
End Try
Return False
End Sub
#If Java
import java.io.File;
import java.io.IOException;
import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
// Convert jpg to png
public static void ConvertJpg2Png (String input, String output) throws Exception
{
BufferedImage originalImage = ImageIO.read(new File(input));
File file = new File(output);
ImageIO.write(originalImage, "png", file);
}
#End If