Compare commits

...

5 Commits

Author SHA1 Message Date
Harald Kuhr f367cee35b Update ci.yml 2025-10-09 08:53:16 +02:00
dependabot[bot] 9c25c962cc Bump github/codeql-action from 3.30.6 to 4.30.7 in /.github/workflows
Bumps [github/codeql-action](https://github.com/github/codeql-action) from 3.30.6 to 4.30.7.
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](https://github.com/github/codeql-action/compare/64d10c13136e1c5bce3e5fbde8d4906eeaafc885...e296a935590eb16afc0c0108289f68c87e2a89a5)

---
updated-dependencies:
- dependency-name: github/codeql-action
  dependency-version: 4.30.7
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-10-09 08:41:40 +02:00
zcronix 1328dbf763 Handle lossless JPEG with non-zero point transform (#1183)
* Handle lossless JPEG with non-zero point transform (Pt parameter)
* Add unit test
* Inserting a fix for last pixel not being output
* Address issues from code review

---------

Co-authored-by: Harald Kuhr <harald.kuhr@gmail.com>
2025-10-03 10:49:40 +02:00
dependabot[bot] 8bccdef371 Bump github/codeql-action from 3.30.5 to 3.30.6 in /.github/workflows
Bumps [github/codeql-action](https://github.com/github/codeql-action) from 3.30.5 to 3.30.6.
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](https://github.com/github/codeql-action/compare/3599b3baa15b485a2e49ef411a7a4bb2452e7f93...64d10c13136e1c5bce3e5fbde8d4906eeaafc885)

---
updated-dependencies:
- dependency-name: github/codeql-action
  dependency-version: 3.30.6
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-10-03 10:45:04 +02:00
Harald Kuhr 2d6f7d89fa JDK 25 seems to have added Exif thumbnail read support 2025-10-03 10:42:16 +02:00
8 changed files with 96 additions and 9 deletions
+2 -2
View File
@@ -43,7 +43,7 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [ ubuntu-latest, windows-latest, macos-13 ]
os: [ ubuntu-latest, windows-latest, macos-14 ]
runs-on: ${{ matrix.os }}
permissions:
checks: write
@@ -51,7 +51,7 @@ jobs:
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
- uses: actions/setup-java@dded0888837ed1f317902acf8a20df0ad188d165 # v5.0.0
with:
distribution: 'temurin'
distribution: 'zulu'
java-version: '8'
java-package: jdk
cache: 'maven'
+3 -3
View File
@@ -37,7 +37,7 @@ jobs:
# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@3599b3baa15b485a2e49ef411a7a4bb2452e7f93 # v3.30.5
uses: github/codeql-action/init@e296a935590eb16afc0c0108289f68c87e2a89a5 # v4.30.7
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
@@ -51,7 +51,7 @@ jobs:
# Autobuild attempts to build any compiled languages (C/C++, C#, Go, Java, or Swift).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@3599b3baa15b485a2e49ef411a7a4bb2452e7f93 # v3.30.5
uses: github/codeql-action/autobuild@e296a935590eb16afc0c0108289f68c87e2a89a5 # v4.30.7
# ℹ️ Command-line programs to run using the OS shell.
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
@@ -64,6 +64,6 @@ jobs:
# ./location_of_script_within_repo/buildscript.sh
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@3599b3baa15b485a2e49ef411a7a4bb2452e7f93 # v3.30.5
uses: github/codeql-action/analyze@e296a935590eb16afc0c0108289f68c87e2a89a5 # v4.30.7
with:
category: "/language:${{matrix.language}}"
+1 -1
View File
@@ -57,6 +57,6 @@ jobs:
# Upload the results to GitHub's code scanning dashboard.
- name: "Upload to code-scanning"
uses: github/codeql-action/upload-sarif@3599b3baa15b485a2e49ef411a7a4bb2452e7f93 # v3.30.5
uses: github/codeql-action/upload-sarif@e296a935590eb16afc0c0108289f68c87e2a89a5 # v4.30.7
with:
sarif_file: results.sarif
@@ -212,7 +212,9 @@ final class JPEGLosslessDecoder {
final int[] firstValue = new int[numComp];
for (int i = 0; i < numComp; i++) {
firstValue[i] = (1 << (precision - 1));
// scan.approxLow is the point transformation (Pt) value
// ref. ISO/IEC 10918-1 H.1.2.1
firstValue[i] = (1 << (precision - scan.approxLow - 1));
}
final int[] pred = new int[numComp];
@@ -232,6 +234,11 @@ final class JPEGLosslessDecoder {
output(pred);
current = decode(pred, temp, index);
}
if ((current == JPEG.EOI) && (xLoc == xDim - 1) && (yLoc == yDim - 1)) {
// Output value left in pred if EOI is hit while decoding last pixel
output(pred);
}
break; //current=MARKER
}
@@ -268,6 +275,17 @@ final class JPEGLosslessDecoder {
// TODO oe: 05.05.2018 Is it correct loop? Content of outputData from previous iteration is always lost.
} while ((current != JPEG.EOI) && ((xLoc < xDim) && (yLoc < yDim)) && (scanNum == 0));
// Apply point transform to output. This must be done after it has finished being
// used for predictive purposes.
if (scan.approxLow != 0) {
for (int componentIndex = 0; componentIndex < numComp; ++componentIndex) {
int[] comp = outputData[componentIndex];
for (int i = 0; i < comp.length; i++) {
comp[i] = mask & (comp[i] << scan.approxLow);
}
}
}
return outputData;
}
@@ -329,9 +347,11 @@ final class JPEGLosslessDecoder {
private int decodeSingle(final int[] prev, final int[] temp, final int[] index) throws IOException {
// At the beginning of the first line and
// at the beginning of each restart interval the prediction value of 2P – 1 is used, where P is the input precision.
// If the point transformation parameter (see A.4) is non-zero, the prediction value at the beginning of the first lines and the
// beginning of each restart interval is 2P – Pt – 1 , where Pt is the value of the point transformation parameter
if (restarting) {
restarting = false;
prev[0] = (1 << (frame.samplePrecision - 1));
prev[0] = (1 << (frame.samplePrecision - scan.approxLow - 1));
}
else {
final int[] outputData = this.outputData[0];
@@ -686,7 +706,7 @@ final class JPEGLosslessDecoder {
return getPreviousY(data);
}
else {
return (1 << (frame.samplePrecision - 1));
return (1 << (frame.samplePrecision - scan.approxLow - 1));
}
}
@@ -2033,4 +2033,65 @@ public class JPEGImageReaderTest extends ImageReaderAbstractTest<JPEGImageReader
}
});
}
@Test
public void testReadLosslessJPEGGradient() throws IOException {
JPEGImageReader reader = createReader();
try (ImageInputStream stream = ImageIO.createImageInputStream(getClassLoaderResource("/jpeg-lossless/gradient_ls.jpg"))) {
reader.setInput(stream);
assertEquals(256, reader.getWidth(0));
assertEquals(256, reader.getHeight(0));
BufferedImage image = reader.read(0, null);
assertNotNull(image);
assertEquals(256, image.getWidth());
assertEquals(256, image.getHeight());
assertEquals(16, image.getColorModel().getComponentSize(0));
for (int y = 0; y < 256; y++) {
for (int x = 0; x < 256; x++) {
assertEquals((y << 8) | x, image.getRaster().getSample(x, y, 0));
}
}
}
finally {
reader.dispose();
}
}
@Test
public void testReadLosslessJPEGGradientWithPointTransform() throws IOException {
JPEGImageReader reader = createReader();
try (ImageInputStream stream = ImageIO.createImageInputStream(getClassLoaderResource("/jpeg-lossless/gradient_ls_pt.jpg"))) {
reader.setInput(stream);
assertEquals(256, reader.getWidth(0));
assertEquals(256, reader.getHeight(0));
BufferedImage image = reader.read(0, null);
assertNotNull(image);
assertEquals(256, image.getWidth());
assertEquals(256, image.getHeight());
assertEquals(16, image.getColorModel().getComponentSize(0));
for (int y = 0; y < 256; y++) {
for (int x = 0; x < 256; x++) {
int expected = (y << 8) | x;
// Simulate effect of precision loss due to point transform = 4
expected = (expected >> 4) << 4;
assertEquals(expected, image.getRaster().getSample(x, y, 0));
}
}
}
finally {
reader.dispose();
}
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.2 KiB

@@ -111,6 +111,12 @@ public class JPEGImageReaderTest extends ImageReaderAbstractTest<JPEGImageReader
super.testReadAsRenderedImageIndexOutOfBounds();
}
@Test
@Disabled("JDK 25 now supports reading Exif thumbnails, but does not report thumbnail progress")
public void testThumbnailProgress() throws IOException {
super.testThumbnailProgress();
}
@Test
@Disabled("No test data with JFIF thumbnail")
@Override