If transforming and outputting a JPEG file, output the transformed file directly instead of decompressing/recompressing it
This commit is contained in:
@@ -80,7 +80,7 @@ public class TJExample {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private final static String sampName[] = {
|
private final static String sampName[] = {
|
||||||
"4:4:4", "4:2:2", "4:2:0", "Grayscale"
|
"4:4:4", "4:2:2", "4:2:0", "Grayscale", "4:4:0"
|
||||||
};
|
};
|
||||||
|
|
||||||
public static void main(String argv[]) {
|
public static void main(String argv[]) {
|
||||||
@@ -122,8 +122,7 @@ public class TJExample {
|
|||||||
}
|
}
|
||||||
if(match != 1) usage();
|
if(match != 1) usage();
|
||||||
}
|
}
|
||||||
if(argv[i].substring(0, 2).equalsIgnoreCase("-h")
|
if(argv[i].equalsIgnoreCase("-h") || argv[i].equalsIgnoreCase("-?"))
|
||||||
|| argv[i].equalsIgnoreCase("-?"))
|
|
||||||
usage();
|
usage();
|
||||||
if(argv[i].length() > 2
|
if(argv[i].length() > 2
|
||||||
&& argv[i].substring(0, 3).equalsIgnoreCase("-sa")) {
|
&& argv[i].substring(0, 3).equalsIgnoreCase("-sa")) {
|
||||||
@@ -220,6 +219,15 @@ public class TJExample {
|
|||||||
+ " pixels, " + sampName[inSubsamp] + " subsampling");
|
+ " pixels, " + sampName[inSubsamp] + " subsampling");
|
||||||
if(outSubsamp < 0) outSubsamp = inSubsamp;
|
if(outSubsamp < 0) outSubsamp = inSubsamp;
|
||||||
|
|
||||||
|
if(outFormat.equalsIgnoreCase("jpg") && (xform.op != TJ.XFORM_NONE
|
||||||
|
|| xform.options != 0)) {
|
||||||
|
file = new File(argv[1]);
|
||||||
|
FileOutputStream fos = new FileOutputStream(file);
|
||||||
|
fos.write(tjd.getJPEGBuf(), 0, tjd.getJPEGSize());
|
||||||
|
fos.close();
|
||||||
|
System.exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
if(scaleNum != 1 || scaleDenom != 1) {
|
if(scaleNum != 1 || scaleDenom != 1) {
|
||||||
width = (width * scaleNum + scaleDenom - 1) / scaleDenom;
|
width = (width * scaleNum + scaleDenom - 1) / scaleDenom;
|
||||||
height = (height * scaleNum + scaleDenom - 1) / scaleDenom;
|
height = (height * scaleNum + scaleDenom - 1) / scaleDenom;
|
||||||
|
|||||||
Reference in New Issue
Block a user