[Git][java-team/libthumbnailator-java][upstream] New upstream version 0.4.17
Markus Koschany (@apo)
gitlab at salsa.debian.org
Sat Feb 12 21:00:13 GMT 2022
Markus Koschany pushed to branch upstream at Debian Java Maintainers / libthumbnailator-java
Commits:
32d64434 by Markus Koschany at 2022-02-12T21:56:42+01:00
New upstream version 0.4.17
- - - - -
4 changed files:
- README.md
- pom.xml
- src/main/java/net/coobird/thumbnailator/Thumbnails.java
- src/main/java/net/coobird/thumbnailator/tasks/io/InputStreamImageSource.java
Changes:
=====================================
README.md
=====================================
@@ -1,4 +1,4 @@
-_*January 2, 2022: Thumbnailator 0.4.16 has been released!
+_*February 11, 2022: Thumbnailator 0.4.17 has been released!
See [Changes](https://github.com/coobird/thumbnailator/wiki/Changes) for details.*_
_*Thumbnailator is now available through
@@ -49,7 +49,7 @@ The following pages have more information on what _Thumbnailator_ can do:
* [Features](https://github.com/coobird/thumbnailator/wiki/Features)
* [Examples](https://github.com/coobird/thumbnailator/wiki/Examples)
-* [Thumbnailator API Documentation](https://coobird.github.io/thumbnailator/javadoc/0.4.16/)
+* [Thumbnailator API Documentation](https://coobird.github.io/thumbnailator/javadoc/0.4.17/)
* [Frequently Asked Questions](https://github.com/coobird/thumbnailator/wiki/FAQ)
# Disclaimer
=====================================
pom.xml
=====================================
@@ -2,7 +2,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>net.coobird</groupId>
<artifactId>thumbnailator</artifactId>
- <version>0.4.16</version>
+ <version>0.4.17</version>
<packaging>jar</packaging>
<name>thumbnailator</name>
<description>Thumbnailator - a thumbnail generation library for Java</description>
=====================================
src/main/java/net/coobird/thumbnailator/Thumbnails.java
=====================================
@@ -1,7 +1,7 @@
/*
* Thumbnailator - a thumbnail generation library
*
- * Copyright (c) 2008-2020 Chris Kroells
+ * Copyright (c) 2008-2022 Chris Kroells
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -1051,8 +1051,8 @@ Thumbnails.of(image)
}
/**
- * Specifies the source region from which the thumbnail is to be
- * created from.
+ * Specifies the region of the source image where the thumbnail
+ * will be created from.
* <p>
* Calling this method multiple times will result in an
* {@link IllegalStateException} to be thrown.
@@ -1075,8 +1075,8 @@ Thumbnails.of(image)
}
/**
- * Specifies the source region from which the thumbnail is to be
- * created from.
+ * Specifies the region of the source image where the thumbnail
+ * will be created from.
* <p>
* Calling this method multiple times will result in an
* {@link IllegalStateException} to be thrown.
@@ -1100,15 +1100,15 @@ Thumbnails.of(image)
}
/**
- * Specifies the source region from which the thumbnail is to be
- * created from.
+ * Specifies the region of the source image where the thumbnail
+ * will be created from.
* <p>
* Calling this method multiple times will result in an
* {@link IllegalStateException} to be thrown.
*
- * @param x The horizontal-compoennt of the top left-hand
+ * @param x The horizontal-component of the top left-hand
* corner of the source region.
- * @param y The vertical-compoennt of the top left-hand
+ * @param y The vertical-component of the top left-hand
* corner of the source region.
* @param width Width of the source region.
* @param height Height of the source region.
@@ -1131,8 +1131,8 @@ Thumbnails.of(image)
}
/**
- * Specifies the source region from which the thumbnail is to be
- * created from.
+ * Specifies the region of the source image where the thumbnail
+ * will be created from.
* <p>
* Calling this method multiple times will result in an
* {@link IllegalStateException} to be thrown.
@@ -1164,8 +1164,8 @@ Thumbnails.of(image)
}
/**
- * Specifies the source region from which the thumbnail is to be
- * created from.
+ * Specifies the region of the source image where the thumbnail
+ * will be created from.
* <p>
* Calling this method multiple times will result in an
* {@link IllegalStateException} to be thrown.
@@ -1188,27 +1188,34 @@ Thumbnails.of(image)
}
/**
- * Crops the thumbnail to the size specified when calling the
- * {@link #size(int, int)} method, positioned by the given
- * {@link Position} object.
- * <p>
- * Calling this method will guarantee that the size of the thumbnail
- * will be exactly the dimensions specified in the
- * {@link #size(int, int)} method.
- * <p>
- * Internally, the resizing is performed in two steps.
- * First, the thumbnail will be sized so that one of the dimensions will
- * be sized exactly to the dimension specified in the {@code size}
- * method, while allowing the other dimension to overhang the specified
- * dimension. Then, the thumbnail will be cropped to the dimensions
- * specified in the {@code size} method, positioned using the speficied
- * {@link Position} object.
- * <p>
- * Once this method is called, calling the {@link #scale(double)} method
- * will result in an {@link IllegalStateException}.
- * <p>
- * Calling this method multiple times will result in an
- * {@link IllegalStateException} to be thrown.
+ * Crops the thumbnail at the position specified by {@link Position}.
+ * This method must be used along with the {@link #size(int, int)}
+ * method to specify the size of the thumbnail.
+ *
+ * <p>This method will guarantee that the thumbnail will be exactly
+ * the dimensions specified in the {@link #size(int, int)} method.
+ *
+ * <p>Internally, the resizing is performed in two steps:
+ *
+ * <p>First, the thumbnail will be sized so that one of the dimensions
+ * will be exactly the dimension specified in the {@code size} method.
+ * The other dimension may overhang the specified dimension.
+ * For example, if the {@code .size(200, 200)} is called and the
+ * source image is 400 x 600, the image will be resized to 200 x 300,
+ * internally.
+ *
+ * <p>Next, the resized image will be cropped to the dimensions
+ * specified in the {@code size} method, positioned using
+ * the specified {@link Position} object.
+ * Continuing the example from the previous paragraph, the 200 x 300
+ * image will be cropped to 200 x 200 using the specified positioning.
+ *
+ * <p>Once this method is called, calling the {@link #scale(double)}
+ * or {@link #scale(double, double)} method will throw an
+ * {@link IllegalStateException}.
+ *
+ * <p>Calling this method multiple times will throw an
+ * {@link IllegalStateException}.
*
* @param position The position to which the thumbnail should be
* cropped to. For example, if
=====================================
src/main/java/net/coobird/thumbnailator/tasks/io/InputStreamImageSource.java
=====================================
@@ -1,7 +1,7 @@
/*
* Thumbnailator - a thumbnail generation library
*
- * Copyright (c) 2008-2021 Chris Kroells
+ * Copyright (c) 2008-2022 Chris Kroells
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -210,6 +210,15 @@ public class InputStreamImageSource extends AbstractImageSource<InputStream> {
}
}
+ /**
+ * Debug message, optimized to reduce calls on Arrays.toString.
+ */
+ private void debugln(String format, byte[] array) {
+ if (isDebug) {
+ debugln(format, Arrays.toString(array));
+ }
+ }
+
@Override
public int read(byte[] b, int off, int len) throws IOException {
int bytesRead = is.read(b, off, len);
@@ -243,8 +252,8 @@ public class InputStreamImageSource extends AbstractImageSource<InputStream> {
System.arraycopy(b, off, tmpBuffer, totalRead - bytesRead, bytesRead);
buffer = tmpBuffer;
- debugln("Source: %s", Arrays.toString(b));
- debugln("Buffer: %s", Arrays.toString(buffer));
+ debugln("Source: %s", b);
+ debugln("Buffer: %s", buffer);
while (position < totalRead && (totalRead - position) >= 2) {
debugln("Start loop, position: %s", position);
@@ -285,7 +294,7 @@ public class InputStreamImageSource extends AbstractImageSource<InputStream> {
if (position == 0 && totalRead >= 2) {
// Check the first two bytes of stream to see if SOI exists.
// If SOI is not found, this is not a JPEG.
- debugln("Check if JPEG. buffer: %s", Arrays.toString(buffer));
+ debugln("Check if JPEG. buffer: %s", buffer);
if (!(buffer[position] == (byte) 0xFF && buffer[position + 1] == (byte) 0xD8)) {
// Not SOI, so it's not a JPEG.
// We no longer need to keep intercepting.
@@ -380,6 +389,14 @@ public class InputStreamImageSource extends AbstractImageSource<InputStream> {
}
}
+ if (totalRead <= 6) {
+ // SOI (2 bytes) + marker+length (4 bytes) == 6 bytes
+ // If we didn't find a 2-byte (standalone) marker, then
+ // we'll need to wait around to get enough one for 4-byte.
+ debugln("Not enough data read. Attempt one additional read.");
+ break;
+ }
+
terminateIntercept();
debugln("Shouldn't be here. Terminating intercept.");
break;
View it on GitLab: https://salsa.debian.org/java-team/libthumbnailator-java/-/commit/32d64434072d707df064c24455075d3ab298409d
--
View it on GitLab: https://salsa.debian.org/java-team/libthumbnailator-java/-/commit/32d64434072d707df064c24455075d3ab298409d
You're receiving this email because of your account on salsa.debian.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/pkg-java-commits/attachments/20220212/dcfed237/attachment.htm>
More information about the pkg-java-commits
mailing list