Last active
July 24, 2022 00:12
-
-
Save guymac/b511615b2aefeb46967b84454f715a01 to your computer and use it in GitHub Desktop.
Converting a Jpeg-2000 to TIFF
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.awt.image.BufferedImage; | |
import java.io.File; | |
import java.io.IOException; | |
import javax.imageio.ImageIO; | |
/** | |
* https://github.com/jai-imageio/jai-imageio-core | |
* https://github.com/jai-imageio/jai-imageio-jpeg2000 | |
* | |
* Example of fetching dependencies, compiling, and running. | |
* | |
* wget https://repo1.maven.org/maven2/com/github/jai-imageio/jai-imageio-core/1.4.0/jai-imageio-core-1.4.0.jar | |
* wget https://repo1.maven.org/maven2/com/github/jai-imageio/jai-imageio-jpeg2000/1.4.0/jai-imageio-jpeg2000-1.4.0.jar | |
* | |
* javac jp2_to_tiff.java | |
* | |
* java -cp .:jai-imageio-core-1.4.0.jar:jai-imageio-jpeg2000-1.4.0.jar jp2_to_tiff ESP_074800_1790_RED.JP2 /tmp/test.tiff | |
*/ | |
public class jp2_to_tiff | |
{ | |
public static void main(String[] args) throws IOException | |
{ | |
if (args.length < 2) return; | |
System.err.println("JP2 = " + ImageIO.getImageReadersBySuffix("JP2").hasNext()); | |
BufferedImage img = ImageIO.read(new File(args[0])); | |
if (img == null) | |
{ | |
System.err.println("Could not read " + args[0]); | |
return; | |
} | |
ImageIO.write(img, "TIFF", new File(args[1])); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment