[Git][java-team/libthumbnailator-java][master] 3 commits: New upstream version 0.4.15

Markus Koschany (@apo) gitlab at salsa.debian.org
Sat Dec 18 23:51:24 GMT 2021



Markus Koschany pushed to branch master at Debian Java Maintainers / libthumbnailator-java


Commits:
0c17c3bb by Markus Koschany at 2021-12-19T00:49:17+01:00
New upstream version 0.4.15
- - - - -
7c04991d by Markus Koschany at 2021-12-19T00:49:18+01:00
Update upstream source from tag 'upstream/0.4.15'

Update to upstream version '0.4.15'
with Debian dir 32d5985a5e5a71fc3ddaf8ec1caad47b5ad8db0d
- - - - -
87599884 by Markus Koschany at 2021-12-19T00:49:54+01:00
Update changelog

- - - - -


17 changed files:

- README.md
- debian/changelog
- pom.xml
- src/main/java/net/coobird/thumbnailator/Thumbnailator.java
- src/main/java/net/coobird/thumbnailator/Thumbnails.java
- src/main/java/net/coobird/thumbnailator/builders/ThumbnailParameterBuilder.java
- src/main/java/net/coobird/thumbnailator/filters/Pipeline.java
- src/main/java/net/coobird/thumbnailator/makers/FixedSizeThumbnailMaker.java
- src/main/java/net/coobird/thumbnailator/makers/ScaledThumbnailMaker.java
- src/main/java/net/coobird/thumbnailator/name/ConsecutivelyNumberedFilenames.java
- src/main/java/net/coobird/thumbnailator/name/Rename.java
- src/main/java/net/coobird/thumbnailator/resizers/DefaultResizerFactory.java
- src/main/java/net/coobird/thumbnailator/resizers/Resizers.java
- src/main/java/net/coobird/thumbnailator/tasks/io/ImageSink.java
- src/main/java/net/coobird/thumbnailator/tasks/io/OutputStreamImageSink.java
- src/main/java/net/coobird/thumbnailator/util/ThumbnailatorUtils.java
- + src/test/java/net/coobird/thumbnailator/tasks/io/Issue156OutputStreamImageSinkTest.java


Changes:

=====================================
README.md
=====================================
@@ -1,4 +1,4 @@
-_*March 11, 2021: Thumbnailator 0.4.14 has been released!
+_*December 5, 2021: Thumbnailator 0.4.15 has been released!
 See [Changes](https://github.com/coobird/thumbnailator/wiki/Changes) for details.*_
 
 _*Thumbnailator is now available through


=====================================
debian/changelog
=====================================
@@ -1,3 +1,9 @@
+libthumbnailator-java (0.4.15-1) unstable; urgency=medium
+
+  * New upstream version 0.4.15.
+
+ -- Markus Koschany <apo at debian.org>  Sun, 19 Dec 2021 00:49:44 +0100
+
 libthumbnailator-java (0.4.14-2) unstable; urgency=medium
 
   * Source-only rebuild.


=====================================
pom.xml
=====================================
@@ -2,7 +2,7 @@
   <modelVersion>4.0.0</modelVersion>
   <groupId>net.coobird</groupId>
   <artifactId>thumbnailator</artifactId>
-  <version>0.4.14</version>
+  <version>0.4.15</version>
   <packaging>jar</packaging>
   <name>thumbnailator</name>
   <description>Thumbnailator - a thumbnail generation library for Java</description>
@@ -60,6 +60,12 @@
           <show>public</show>
           <use>false</use>
           <destDir>${project.build.outputDirectory}/javadoc</destDir>
+          <javaApiLinks>
+            <property>
+              <name>api_1.5</name>
+              <value>https://docs.oracle.com/javase/1.5.0/docs/api/</value>
+            </property>
+          </javaApiLinks>
           <archive>
             <manifestEntries>
               <Specification-Title>Thumbnailator API Documentation</Specification-Title>
@@ -130,21 +136,6 @@
           </execution>
         </executions>
       </plugin>
-      <plugin>
-        <groupId>org.apache.maven.plugins</groupId>
-        <artifactId>maven-gpg-plugin</artifactId>
-        <version>1.5</version>
-        <executions>
-          <execution>
-            <id>sign-artifacts</id>
-            <phase>verify</phase>
-            <goals>
-              <goal>sign</goal>
-            </goals>
-          </execution>
-        </executions>
-      </plugin>
-
       <plugin>
         <groupId>com.github.github</groupId>
         <artifactId>site-maven-plugin</artifactId>
@@ -231,6 +222,20 @@
               </execution>
             </executions>
           </plugin>
+          <plugin>
+            <groupId>org.apache.maven.plugins</groupId>
+            <artifactId>maven-gpg-plugin</artifactId>
+            <version>1.5</version>
+            <executions>
+              <execution>
+                <id>sign-artifacts</id>
+                <phase>verify</phase>
+                <goals>
+                  <goal>sign</goal>
+                </goals>
+              </execution>
+            </executions>
+          </plugin>
           <plugin>
             <groupId>org.sonatype.plugins</groupId>
             <artifactId>nexus-staging-maven-plugin</artifactId>


=====================================
src/main/java/net/coobird/thumbnailator/Thumbnailator.java
=====================================
@@ -364,6 +364,7 @@ public final class Thumbnailator {
 	 * @param height		The height of the thumbnail.
 	 * @throws IOException	Thrown when a problem occurs when reading from
 	 * 						{@code File} representing an image file.
+	 * @return 			A collection of {@code File}s to the thumbnails.
 	 * 
 	 * @deprecated		This method has been deprecated in favor of using the
 	 * 					{@link Thumbnails#fromFiles(Iterable)} interface.


=====================================
src/main/java/net/coobird/thumbnailator/Thumbnails.java
=====================================
@@ -78,21 +78,26 @@ import net.coobird.thumbnailator.tasks.io.URLImageSource;
 import net.coobird.thumbnailator.util.ThumbnailatorUtils;
 
 /**
+ * <p>
  * Provides a fluent interface to create thumbnails.
+ * </p>
  * <p>
  * This is the main entry point for creating thumbnails with Thumbnailator.
+ * </p>
  * <p>
  * By using the Thumbnailator's fluent interface, it is possible to write
  * thumbnail generation code which resembles written English.
+ * </p>
  * <DL>
  * <DT><B>Usage:</B></DT>
  * <DD>
+ * <p>
  * The following example code demonstrates how to use the fluent interface
  * to create a thumbnail from multiple files from a directory, resizing them to
  * a maximum of 200 pixels by 200 pixels while preserving the aspect ratio of
  * the original, then saving the resulting thumbnails as JPEG images with file
  * names having {@code thumbnail.} appended to the beginning of the file name.
- * <p>
+ * </p>
  * <pre>
 Thumbnails.of(directory.listFiles())
     .size(200, 200)
@@ -105,21 +110,25 @@ Thumbnails.of(directory.listFiles())
  * </pre>
  * </DD>
  * </DL>
+ * <p>
  * For more examples, please visit the <a href="http://code.google.com/p/thumbnailator/">
  * Thumbnailator</a> project page.
- * <p> 
+ * </p>
  * <h2>Important Implementation Notes</h2>
+ * <p>
  * Upon calling one of the {@code Thumbnails.of(...)} methods, <em>in the
  * current implementation</em>, an instance of an inner class of this class is
  * returned. In most cases, the returned instance should not be used by
  * storing it in a local variable, as changes in the internal implementation
  * could break code in the future.
+ * </p>
  * <p>
  * As a rule of thumb, <em>always method chain from the {@code Thumbnails.of}
  * all the way until the output method (e.g. {@code toFile}, {@code asBufferedImage},
  * etc.) is called without breaking them down into single statements.</em>
  * See the "Usage" section above for the intended use of the Thumbnailator's
- * fluent interface. 
+ * fluent interface.
+ * </p>
  * <DL>
  * <DT><B>Unintended Use:</B></DT>
  * <DD>
@@ -376,7 +385,7 @@ public final class Thumbnails {
 	 * and less future-proof, as changes to this class (which is just an
 	 * inner class of the {@link Thumbnails} class) can lead to broken code  
 	 * when attempting to use future releases of Thumbnailator.
-	 * <p>
+	 * </p>
 	 * <DL>
 	 * <DT><B>Intended Use:</B></DT>
 	 * <DD>
@@ -1163,6 +1172,7 @@ Thumbnails.of(image)
 		 * 
 		 * @param region		A rectangular region which specifies the source
 		 * 						region to use when creating the thumbnail.
+		 * @return				Reference to this object.
 		 * @throws NullPointerException		If the region is {@code null}.
 		 * @since 	0.3.4
 		 */
@@ -1205,6 +1215,7 @@ Thumbnails.of(image)
 		 * 						{@link Positions#CENTER} is specified, the
 		 * 						resulting thumbnail will be made by cropping to
 		 * 						the center of the image.
+		 * @return				Reference to this object.
 		 * @throws NullPointerException		If the position is {@code null}.
 		 * @since 	0.4.0
 		 */
@@ -1244,7 +1255,7 @@ Thumbnails.of(image)
 		 * 							will not be altered. For specific behavior,
 		 * 							please refer to the specific output methods
 		 * 							listed above.
-		 * 						
+		 * @return					Reference to this object.
 		 * @since 	0.3.7
 		 */
 		public Builder<T> allowOverwrite(boolean allowOverwrite) {
@@ -1517,6 +1528,13 @@ Thumbnails.of(image)
 		 * Calling this method multiple times, or the
 		 * {@link #outputQuality(double)} in conjunction with this method will
 		 * result in an {@link IllegalStateException} to be thrown.
+		 * <p>
+		 * <em>
+		 * Implementation note:
+		 * Compression quality settings are ignored when the underlying
+		 * image writer does not support compression. This behavior is subject
+		 * to change in the future.
+		 * </em>
 		 * 
 		 * @param quality		The compression quality to use when writing
 		 * 						the thumbnail.
@@ -1560,6 +1578,13 @@ Thumbnails.of(image)
 		 * Calling this method multiple times, or the
 		 * {@link #outputQuality(float)} in conjunction with this method will
 		 * result in an {@link IllegalStateException} to be thrown.
+		 * <p>
+		 * <em>
+		 * Implementation note:
+		 * Compression quality settings are ignored when the underlying
+		 * image writer does not support compression. This behavior is subject
+		 * to change in the future.
+		 * </em>
 		 * 
 		 * @param quality		The compression quality to use when writing
 		 * 						the thumbnail.
@@ -1714,6 +1739,13 @@ Thumbnails.of(image)
 		 * {@link #outputFormat} method is disabled, in order to prevent
 		 * cases where the output format type does not exist in the format
 		 * specified for the {@code outputFormat} method.
+		 * <p>
+		 * <em>
+		 * Implementation note:
+		 * Compression format type settings are ignored when the underlying
+		 * image writer does not support compression. This behavior is subject
+		 * to change in the future.
+		 * </em>
 		 *
 		 * @param formatType	The compression format type
 		 * @return				Reference to this object.
@@ -1785,24 +1817,30 @@ Thumbnails.of(image)
 		}
 		
 		/**
+		 * <p>
 		 * Sets the image of the watermark to apply on the thumbnail.
+		 * </p>
 		 * <p>
 		 * This method is a convenience method for the
 		 * {@link #watermark(Position, BufferedImage, float)} method, where
 		 * the opacity is 50%, and the position is set to center of the
 		 * thumbnail:
-		 * <p>
+		 * </p>
 		 * <pre>
 watermark(Positions.CENTER, image, 0.5f);
 		 * </pre>
+		 * <p>
 		 * This method can be called multiple times to apply multiple
 		 * watermarks.
+		 * </p>
 		 * <p>
 		 * If multiple watermarks are to be applied, the watermarks will be
 		 * applied in the order that this method is called.
+		 * </p>
 		 * <p>
 		 * Calling this method to set this parameter is optional.
-		 * 
+		 * </p>
+		 *
 		 * @param image			The image of the watermark.
 		 * @return				Reference to this object.
 		 */
@@ -1811,23 +1849,29 @@ watermark(Positions.CENTER, image, 0.5f);
 		}
 		
 		/**
+		 * <p>
 		 * Sets the image and opacity of the watermark to apply on
 		 * the thumbnail.
+		 * </p>
 		 * <p>
 		 * This method is a convenience method for the
 		 * {@link #watermark(Position, BufferedImage, float)} method, where
 		 * the opacity is 50%:
-		 * <p>
+		 * </p>
 		 * <pre>
 watermark(Positions.CENTER, image, opacity);
 		 * </pre>
+		 * <p>
 		 * This method can be called multiple times to apply multiple
 		 * watermarks.
+		 * </p>
 		 * <p>
 		 * If multiple watermarks are to be applied, the watermarks will be
 		 * applied in the order that this method is called.
+		 * </p>
 		 * <p>
 		 * Calling this method to set this parameter is optional.
+		 * </p>
 		 * 
 		 * @param image			The image of the watermark.
 		 * @param opacity		The opacity of the watermark.
@@ -2138,16 +2182,20 @@ watermark(Positions.CENTER, image, opacity);
 		}
 		
 		/**
+		 * <p>
 		 * Create the thumbnails and return as a {@link List} of
 		 * {@link BufferedImage}s.
+		 * </p>
+		 * <p><strong>Note about performance</strong></p>
 		 * <p>
-		 * <h3>Note about performance</h3>
 		 * If there are many thumbnails generated at once, it is possible that
 		 * the Java virtual machine's heap space will run out and an
 		 * {@link OutOfMemoryError} could result.
+		 * </p>
 		 * <p>
 		 * If many thumbnails are being processed at once, then using the
 		 * {@link #iterableBufferedImages()} method would be preferable.
+		 * </p>
 		 * 
 		 * @return		A list of thumbnails.
 		 * @throws IOException					If an problem occurred during


=====================================
src/main/java/net/coobird/thumbnailator/builders/ThumbnailParameterBuilder.java
=====================================
@@ -38,11 +38,13 @@ import net.coobird.thumbnailator.resizers.Resizer;
 import net.coobird.thumbnailator.resizers.ResizerFactory;
 
 /**
+ * <p>
  * A builder for generating {@link ThumbnailParameter}.
+ * </p>
  * <p>
  * The default values assigned to the {@link ThumbnailParameter} created by
  * the {@link ThumbnailParameterBuilder} are as follows:
- * <p>
+ * </p>
  * <dl>
  * <dt>width</dt>
  * <dd>Unassigned. Must be set by the {@link #size(int, int)} method.</dd>


=====================================
src/main/java/net/coobird/thumbnailator/filters/Pipeline.java
=====================================
@@ -93,6 +93,8 @@ public final class Pipeline implements ImageFilter {
 	
 	/**
 	 * Adds an {@code ImageFilter} to the pipeline.
+	 *
+	 * @param filter		An {@code ImageFilter}.
 	 */
 	public void add(ImageFilter filter) {
 		if (filter == null) {
@@ -104,6 +106,8 @@ public final class Pipeline implements ImageFilter {
 	
 	/**
 	 * Adds an {@code ImageFilter} to the beginning of the pipeline.
+	 *
+	 * @param filter		An {@code ImageFilter}.
 	 */
 	public void addFirst(ImageFilter filter) {
 		if (filter == null) {


=====================================
src/main/java/net/coobird/thumbnailator/makers/FixedSizeThumbnailMaker.java
=====================================
@@ -27,8 +27,10 @@ package net.coobird.thumbnailator.makers;
 import java.awt.image.BufferedImage;
 
 /**
+ * <p>
  * A {@link ThumbnailMaker} which resizes an image to a specified dimension
  * when producing a thumbnail.
+ * </p>
  * <p>
  * Optionally, if the aspect ratio of the thumbnail is to be maintained the same
  * as the original image (by calling the {@link #keepAspectRatio(boolean)}
@@ -36,17 +38,19 @@ import java.awt.image.BufferedImage;
  * {@link #size(int, int)} method, {@link #FixedSizeThumbnailMaker(int, int)} or
  * {@link #FixedSizeThumbnailMaker(int, int, boolean)} constructor will be used
  * as the maximum constraint of dimensions of the thumbnail.
+ * </p>
  * <p>
  * In other words, when the aspect ratio is to be kept constant, then
  * thumbnails which are created will be sized to fit inside the dimensions
  * specified by the size parameter.
+ * </p>
  * <p>
  * Upon calculating the size of the thumbnail, if any of the dimensions are
  * {@code 0}, then that dimension will be promoted to {@code 1}, regardless of
  * whether the aspect ratio of the original image is to be maintained. This will
  * lead to some thumbnails not preserving the aspect ratio of the original
  * image, even if {@link #keepAspectRatio(boolean)} has been {@code true}.
- * <p>
+ * </p>
  * <DL>
  * <DT><B>Usage:</B></DT>
  * <DD>


=====================================
src/main/java/net/coobird/thumbnailator/makers/ScaledThumbnailMaker.java
=====================================
@@ -27,14 +27,16 @@ package net.coobird.thumbnailator.makers;
 import java.awt.image.BufferedImage;
 
 /**
+ * <p>
  * A {@link ThumbnailMaker} which scales an image by a specified scaling factor
  * when producing a thumbnail.
+ * </p>
  * <p>
  * Upon calculating the size of the thumbnail, if any of the dimensions are
  * {@code 0}, then that dimension will be promoted to {@code 1}. This will
  * cause some resizing operations to not preserve the aspect ratio of the
  * original image.
- * <p>
+ * </p>
  * <DL>
  * <DT><B>Usage:</B></DT>
  * <DD>
@@ -48,10 +50,11 @@ BufferedImage thumbnail = new ScaledThumbnailMaker()
  * </pre>
  * </DD>
  * </DL>
+ * <p>
  * It is also possible to independently specify the scaling factor for the
  * width and height. (If the two scaling factors are not equal then the aspect
  * ratio of the original image will not be preserved.)
- * <p>
+ * </p>
  * <DL>
  * <DT><B>Usage:</B></DT>
  * <DD>
@@ -65,8 +68,7 @@ BufferedImage thumbnail = new ScaledThumbnailMaker()
  * </pre>
  * </DD>
  * </DL>
- * <DL>
- * 
+ *
  * @author coobird
  *
  */


=====================================
src/main/java/net/coobird/thumbnailator/name/ConsecutivelyNumberedFilenames.java
=====================================
@@ -44,38 +44,46 @@ public class ConsecutivelyNumberedFilenames implements Iterable<File> {
 	private final Iterator<File> iter;
 
 	/**
+	 * <p>
 	 * Instantiates an {@code ConsecutivelyNumberedFilenames} object which
 	 * returns {@link File}s with file names which are consecutively numbered
 	 * beginning from {@code 0}.
-	 * <p>
-	 * <h3>File name sequence</h3>
+	 * </p>
+	 * <p><strong>File name sequence</strong></p>
 	 * <ol>
 	 * <li><code>0</code></li>
 	 * <li><code>1</code></li>
 	 * <li><code>2</code></li>
 	 * <li><code>3</code></li>
 	 * </ol>
+	 * <p>
 	 * and so on.
+	 * </p>
 	 */
 	public ConsecutivelyNumberedFilenames() {
 		this.iter = new ConsecutivelyNumberedFilenamesIterator(new File("").getParentFile(), "%d", 0);
 	}
 
 	/**
+	 * <p>
 	 * Instantiates an {@code ConsecutivelyNumberedFilenames} object which
 	 * returns {@link File}s with file names which are consecutively numbered
 	 * beginning from the given value.
+	 * </p>
+	 * <p><strong>File name sequence</strong></p>
 	 * <p>
-	 * <h3>File name sequence</h3>
 	 * For a case where the given value is {@code 5}:
+	 * </p>
 	 * <ol>
 	 * <li><code>5</code></li>
 	 * <li><code>6</code></li>
 	 * <li><code>7</code></li>
 	 * <li><code>8</code></li>
 	 * </ol>
+	 * <p>
 	 * and so on.
-	 * 
+	 * </p>
+	 *
 	 * @param start		The value from which to start counting.
 	 */
 	public ConsecutivelyNumberedFilenames(int start) {
@@ -83,20 +91,25 @@ public class ConsecutivelyNumberedFilenames implements Iterable<File> {
 	}
 	
 	/**
+	 * <p>
 	 * Instantiates an {@code ConsecutivelyNumberedFilenames} object which
 	 * returns {@link File}s with file names which are consecutively numbered
 	 * beginning from {@code 0}, with the directory specified.
+	 * </p>
+	 * <p><strong>File name sequence</strong></p>
 	 * <p>
-	 * <h3>File name sequence</h3>
 	 * For a case where the parent directory is {@code /foo/bar/}:
+	 * </p>
 	 * <ol>
 	 * <li><code>/foo/bar/0</code></li>
 	 * <li><code>/foo/bar/1</code></li>
 	 * <li><code>/foo/bar/2</code></li>
 	 * <li><code>/foo/bar/3</code></li>
 	 * </ol>
+	 * <p>
 	 * and so on.
-	 * 
+	 * </p>
+	 *
  	 * @param dir			The directory in which the files are to be located.
  	 * @throws IOException	If the specified directory path is not a directory,
  	 * 						or if does not exist.
@@ -107,26 +120,32 @@ public class ConsecutivelyNumberedFilenames implements Iterable<File> {
 	}
 	
 	/**
+	 * <p>
 	 * Instantiates an {@code ConsecutivelyNumberedFilenames} object which
 	 * returns {@link File}s with file names which are based on a format string.
 	 * The numbering will be consecutive from {@code 0}.
+	 * </p>
 	 * <p>
 	 * The format string should contain the string {@code %d} which will be
 	 * replaced with a consecutively counted number. Additional formatting
 	 * can be applied. For more details, please refer to the section on
 	 * <em>Numeric</em> formatting in the Java API specification for the
 	 * {@link Formatter} class.
+	 * </p>
+	 * <p><strong>File name sequence</strong></p>
 	 * <p>
-	 * <h3>File name sequence</h3>
 	 * For a case where the format string is {@code image-%d}:
+	 * </p>
 	 * <ol>
 	 * <li><code>image-0</code></li>
 	 * <li><code>image-1</code></li>
 	 * <li><code>image-2</code></li>
 	 * <li><code>image-3</code></li>
 	 * </ol>
+	 * <p>
 	 * and so on.
-	 * 
+	 * </p>
+	 *
 	 * @param format		The format string to use.
 	 */
 	public ConsecutivelyNumberedFilenames(String format) {
@@ -134,21 +153,26 @@ public class ConsecutivelyNumberedFilenames implements Iterable<File> {
 	}
 
 	/**
+	 * <p>
 	 * Instantiates an {@code ConsecutivelyNumberedFilenames} object which
 	 * returns {@link File}s with file names which are consecutively numbered
 	 * beginning from from the given value, with the directory specified.
+	 * </p>
+	 * <p><strong>File name sequence</strong></p>
 	 * <p>
-	 * <h3>File name sequence</h3>
 	 * For a case where the parent directory is {@code /foo/bar/}, and the
 	 * specified value is {@code 5}:
+	 * </p>
 	 * <ol>
 	 * <li><code>/foo/bar/5</code></li>
 	 * <li><code>/foo/bar/6</code></li>
 	 * <li><code>/foo/bar/7</code></li>
 	 * <li><code>/foo/bar/8</code></li>
 	 * </ol>
+	 * <p>
 	 * and so on.
-	 * 
+	 * </p>
+	 *
 	 * @param dir			The directory in which the files are to be located.
 	 * @param start			The value from which to start counting.
  	 * @throws IOException	If the specified directory path is not a directory,
@@ -160,28 +184,34 @@ public class ConsecutivelyNumberedFilenames implements Iterable<File> {
 	}
 	
 	/**
+	 * <p>
 	 * Instantiates an {@code ConsecutivelyNumberedFilenames} object which
 	 * returns {@link File}s with file names which are based on a format string,
 	 * located in the directory specified. The numbering will be consecutively
 	 * counted from {@code 0}.
+	 * </p>
 	 * <p>
 	 * The format string should contain the string {@code %d} which will be
 	 * replaced with a consecutively counted number. Additional formatting
 	 * can be applied. For more details, please refer to the section on
 	 * <em>Numeric</em> formatting in the Java API specification for the
 	 * {@link Formatter} class.
+	 * </p>
+	 * <p><strong>File name sequence</strong></p>
 	 * <p>
-	 * <h3>File name sequence</h3>
 	 * For a case where the parent directory is {@code /foo/bar/},
 	 * with the format string {@code image-%d}:
+	 * </p>
 	 * <ol>
 	 * <li><code>/foo/bar/image-0</code></li>
 	 * <li><code>/foo/bar/image-1</code></li>
 	 * <li><code>/foo/bar/image-2</code></li>
 	 * <li><code>/foo/bar/image-3</code></li>
 	 * </ol>
+	 * <p>
 	 * and so on.
-	 * 
+	 * </p>
+	 *
 	 * @param dir			The directory in which the files are to be located.
 	 * @param format		The format string to use.
  	 * @throws IOException	If the specified directory path is not a directory,
@@ -193,27 +223,33 @@ public class ConsecutivelyNumberedFilenames implements Iterable<File> {
 	}
 
 	/**
+	 * <p>
 	 * Instantiates an {@code ConsecutivelyNumberedFilenames} object which
 	 * returns {@link File}s with file names which are based on a format string.
 	 * The numbering will be consecutive from the specified value.
+	 * </p>
 	 * <p>
 	 * The format string should contain the string {@code %d} which will be
 	 * replaced with a consecutively counted number. Additional formatting
 	 * can be applied. For more details, please refer to the section on
 	 * <em>Numeric</em> formatting in the Java API specification for the
 	 * {@link Formatter} class.
+	 * </p>
+	 * <p><strong>File name sequence</strong></p>
 	 * <p>
-	 * <h3>File name sequence</h3>
 	 * For a case where the parent directory is {@code /foo/bar/}, and the
 	 * specified value is {@code 5}, with the format string {@code image-%d}:
+	 * </p>
 	 * <ol>
 	 * <li><code>image-5</code></li>
 	 * <li><code>image-6</code></li>
 	 * <li><code>image-7</code></li>
 	 * <li><code>image-8</code></li>
 	 * </ol>
+	 * <p>
 	 * and so on.
-	 * 
+	 * </p>
+	 *
 	 * @param format		The format string to use.
 	 * @param start			The value from which to start counting.
 	 */
@@ -222,28 +258,34 @@ public class ConsecutivelyNumberedFilenames implements Iterable<File> {
 	}
 
 	/**
+	 * <p>
 	 * Instantiates an {@code ConsecutivelyNumberedFilenames} object which
 	 * returns {@link File}s with file names which are based on a format string,
 	 * located in the directory specified. The numbering will be consecutive
 	 * from the specified value.
+	 * </p>
 	 * <p>
 	 * The format string should contain the string {@code %d} which will be
 	 * replaced with a consecutively counted number. Additional formatting
 	 * can be applied. For more details, please refer to the section on
 	 * <em>Numeric</em> formatting in the Java API specification for the
 	 * {@link Formatter} class.
+	 * </p>
+	 * <p><strong>File name sequence</strong></p>
 	 * <p>
-	 * <h3>File name sequence</h3>
 	 * For a case where the parent directory is {@code /foo/bar/}, and the
 	 * specified value is {@code 5}, with format string {@code image-%d}:
+	 * </p>
 	 * <ol>
 	 * <li><code>/foo/bar/image-5</code></li>
 	 * <li><code>/foo/bar/image-6</code></li>
 	 * <li><code>/foo/bar/image-7</code></li>
 	 * <li><code>/foo/bar/image-8</code></li>
 	 * </ol>
+	 * <p>
 	 * and so on.
-	 * 
+	 * </p>
+	 *
 	 * @param dir			The directory in which the files are to be located.
 	 * @param format		The format string to use.
 	 * @param start			The value from which to start counting.


=====================================
src/main/java/net/coobird/thumbnailator/name/Rename.java
=====================================
@@ -34,17 +34,17 @@ import net.coobird.thumbnailator.ThumbnailParameter;
  */
 public abstract class Rename {
 	/**
+	 * <p>
 	 * A {@code Rename} which does not alter the given file name.
+	 * </p>
+	 * <p>
+	 * For example, given {@code picture.jpg}, result is {@code picture.jpg}.
+	 * </p>
 	 * <p>
 	 * Note: The {@link #apply(String, ThumbnailParameter)} method does not use
 	 * the {@code param} parameter. A value of {@code null} for {@code param} is
 	 * permitted.
-	 * <p>
-	 * <dt>Example</dt>
-	 * <ul>
-	 * <li>Before: {@code picture.jpg}</li>
-	 * <li>After: {@code picture.jpg}</li>
-	 * </ul>
+	 * </p>
 	 */
 	public static final Rename NO_CHANGE = new Rename() {
 		@Override
@@ -54,17 +54,18 @@ public abstract class Rename {
 	};
 	
 	/**
+	 * <p>
 	 * Appends {@code thumbnail.} to the beginning of the file name.
+	 * </p>
+	 * <p>
+	 * For example, given {@code picture.jpg}, result is
+	 * {@code thumbnail.picture.jpg}.
+	 * </p>
 	 * <p>
 	 * Note: The {@link #apply(String, ThumbnailParameter)} method does not use
 	 * the {@code param} parameter. A value of {@code null} for {@code param} is
 	 * permitted.
-	 * <p>
-	 * <dt>Example</dt>
-	 * <ul>
-	 * <li>Before: {@code picture.jpg}</li>
-	 * <li>After: {@code thumbnail.picture.jpg}</li>
-	 * </ul>
+	 * </p>
 	 */
 	public static final Rename PREFIX_DOT_THUMBNAIL = new Rename() {
 		@Override
@@ -74,17 +75,18 @@ public abstract class Rename {
 	};
 	
 	/**
+	 * <p>
 	 * Appends {@code thumbnail-} to the beginning of the file name.
+	 * </p>
+	 * <p>
+	 * For example, given {@code picture.jpg}, result is
+	 * {@code thumbnail-picture.jpg}.
+	 * </p>
 	 * <p>
 	 * Note: The {@link #apply(String, ThumbnailParameter)} method does not use
 	 * the {@code param} parameter. A value of {@code null} for {@code param} is
 	 * permitted.
-	 * <p>
-	 * <dt>Example</dt>
-	 * <ul>
-	 * <li>Before: {@code picture.jpg}</li>
-	 * <li>After: {@code thumbnail-picture.jpg}</li>
-	 * </ul>
+	 * </p>
 	 * 
 	 * @deprecated 		Please use the correctly spelled
 	 * 					{@link Rename#PREFIX_HYPHEN_THUMBNAIL}. This constant
@@ -94,17 +96,18 @@ public abstract class Rename {
 	public static final Rename PREFIX_HYPTHEN_THUMBNAIL = Rename.PREFIX_HYPHEN_THUMBNAIL;
 	
 	/**
+	 * <p>
 	 * Appends {@code thumbnail-} to the beginning of the file name.
+	 * </p>
+	 * <p>
+	 * For example, given {@code picture.jpg}, result is
+	 * {@code thumbnail-picture.jpg}.
+	 * </p>
 	 * <p>
 	 * Note: The {@link #apply(String, ThumbnailParameter)} method does not use
 	 * the {@code param} parameter. A value of {@code null} for {@code param} is
 	 * permitted.
-	 * <p>
-	 * <dt>Example</dt>
-	 * <ul>
-	 * <li>Before: {@code picture.jpg}</li>
-	 * <li>After: {@code thumbnail-picture.jpg}</li>
-	 * </ul>
+	 * </p>
 	 */
 	public static final Rename PREFIX_HYPHEN_THUMBNAIL = new Rename() {
 		@Override
@@ -114,18 +117,19 @@ public abstract class Rename {
 	};
 	
 	/**
+	 * <p>
 	 * Appends {@code .thumbnail} to the file name prior to the extension of
 	 * the file.
+	 * </p>
+	 * <p>
+	 * For example, given {@code picture.jpg}, result is
+	 * {@code picture.thumbnail.jpg}.
+	 * </p>
 	 * <p>
 	 * Note: The {@link #apply(String, ThumbnailParameter)} method does not use
 	 * the {@code param} parameter. A value of {@code null} for {@code param} is
 	 * permitted.
-	 * <p>
-	 * <dt>Example</dt>
-	 * <ul>
-	 * <li>Before: {@code picture.jpg}</li>
-	 * <li>After: {@code picture.thumbnail.jpg}</li>
-	 * </ul>
+	 * </p>
 	 */
 	public static final Rename SUFFIX_DOT_THUMBNAIL = new Rename() {
 		@Override
@@ -135,18 +139,19 @@ public abstract class Rename {
 	};
 	
 	/**
+	 * <p>
 	 * Appends {@code -thumbnail} to the file name prior to the extension of
 	 * the file.
+	 * </p>
+	 * <p>
+	 * For example, given {@code picture.jpg}, result is
+	 * {@code picture-thumbnail.jpg}.
+	 * </p>
 	 * <p>
 	 * Note: The {@link #apply(String, ThumbnailParameter)} method does not use
 	 * the {@code param} parameter. A value of {@code null} for {@code param} is
 	 * permitted.
-	 * <p>
-	 * <dt>Example</dt>
-	 * <ul>
-	 * <li>Before: {@code picture.jpg}</li>
-	 * <li>After: {@code picture-thumbnail.jpg}</li>
-	 * </ul>
+	 * </p>
 	 * 
 	 * @deprecated 		Please use the correctly spelled
 	 * 					{@link Rename#SUFFIX_HYPHEN_THUMBNAIL}. This constant
@@ -156,18 +161,19 @@ public abstract class Rename {
 	public static final Rename SUFFIX_HYPTHEN_THUMBNAIL = Rename.SUFFIX_HYPHEN_THUMBNAIL;
 	
 	/**
+	 * <p>
 	 * Appends {@code -thumbnail} to the file name prior to the extension of
 	 * the file.
+	 * </p>
+	 * <p>
+	 * For example, given {@code picture.jpg}, result is
+	 * {@code picture-thumbnail.jpg}.
+	 * </p>
 	 * <p>
 	 * Note: The {@link #apply(String, ThumbnailParameter)} method does not use
 	 * the {@code param} parameter. A value of {@code null} for {@code param} is
 	 * permitted.
-	 * <p>
-	 * <dt>Example</dt>
-	 * <ul>
-	 * <li>Before: {@code picture.jpg}</li>
-	 * <li>After: {@code picture-thumbnail.jpg}</li>
-	 * </ul>
+	 * </p>
 	 */
 	public static final Rename SUFFIX_HYPHEN_THUMBNAIL = new Rename() {
 		@Override


=====================================
src/main/java/net/coobird/thumbnailator/resizers/DefaultResizerFactory.java
=====================================
@@ -34,7 +34,7 @@ import java.awt.Dimension;
  * <dl>
  * <dt>{@code Resizer}s returned by this {@code ResizerFactory}:</dt>
  * <dd>
- * The {@link Resizer}s returned by this {@link ResizerFactory} depends upon
+ * The {@link Resizer}s returned by this {@link ResizerFactory} depends on
  * the size of the source and destination images. The conditions and the
  * {@link Resizer}s returned are as follows:
  * 
@@ -71,10 +71,11 @@ import java.awt.Dimension;
  * <DL>
  * <DT><B>Usage:</B></DT>
  * <DD>
+ * <p>
  * The following example code demonstrates how to use {@link DefaultResizerFactory}
  * in order to obtain the optimal {@link Resizer}, and using that in order to
  * perform the resizing operation.
- * <p>
+ * </p>
  * <pre>
 BufferedImage sourceImage = new BufferedImageBuilder(400, 400).build();
 BufferedImage destImage = new BufferedImageBuilder(200, 200).build();
@@ -90,10 +91,11 @@ resizer.resize(sourceImage, destImage);
  * </pre>
  * </DD>
  * </DL>
+ * <p>
  * When a specific {@link Resizer} is required, the {@link Resizers}
  * {@code enum} is another way to obtain {@link Resizer}s.
- * <p>
- * 
+ * </p>
+ *
  * @see Resizers
  *
  * @author coobird


=====================================
src/main/java/net/coobird/thumbnailator/resizers/Resizers.java
=====================================
@@ -27,21 +27,24 @@ package net.coobird.thumbnailator.resizers;
 import java.awt.image.BufferedImage;
 
 /**
+ * <p>
  * This enum can be used to select a specific {@link Resizer} in order
  * to perform a resizing operation.
+ * </p>
  * <p>
  * The instance held by a value of this enum is a single instance. When using
  * specific implementations of {@link Resizer}s, it is preferable to obtain
  * an instance of a {@link Resizer} through this enum or the
  * {@link DefaultResizerFactory} class in order to prevent many instances of the
  * {@link Resizer} class implementations from being instantiated.
- * <p>
+ * </p>
  * <DL>
  * <DT><B>Usage:</B></DT>
  * <DD>
+ * <p>
  * The following example code demonstrates how to use the {@link Resizers} enum
  * in order to resize an image using bilinear interpolation:
- * <p>
+ * </p>
  * <pre>
 BufferedImage sourceImage = new BufferedImageBuilder(400, 400).build();
 BufferedImage destImage = new BufferedImageBuilder(200, 200).build();


=====================================
src/main/java/net/coobird/thumbnailator/tasks/io/ImageSink.java
=====================================
@@ -70,11 +70,15 @@ public interface ImageSink<T> {
 	public void setThumbnailParameter(ThumbnailParameter param);
 	
 	/**
+	 * <p>
 	 * Returns the output format to use from information provided for the
 	 * output image.
+	 * </p>
 	 * <p>
 	 * If the output format cannot be determined, then
 	 * {@link ThumbnailParameter#ORIGINAL_FORMAT} should be returned.
+	 * </p>
+	 * @return 					Name of the preferred output format.
 	 */
 	public String preferredOutputFormatName();
 	


=====================================
src/main/java/net/coobird/thumbnailator/tasks/io/OutputStreamImageSink.java
=====================================
@@ -110,40 +110,55 @@ public class OutputStreamImageSink extends AbstractImageSink<OutputStream> {
 		ImageWriter writer = writers.next();
 		
 		ImageWriteParam writeParam = writer.getDefaultWriteParam();
-		if (writeParam.canWriteCompressed() && param != null) {
-			writeParam.setCompressionMode(ImageWriteParam.MODE_EXPLICIT);
-			
+		if (writeParam.canWriteCompressed()) {
 			/*
 			 * Sets the compression format type, if specified.
-			 * 
+			 *
 			 * Note:
 			 * The value to denote that the codec's default compression type
 			 * should be used is null.
 			 */
-			if (param.getOutputFormatType() != ThumbnailParameter.DEFAULT_FORMAT_TYPE) {
-				writeParam.setCompressionType(param.getOutputFormatType());
+			String compressionType = null;
+			if (param != null && param.getOutputFormatType() != ThumbnailParameter.DEFAULT_FORMAT_TYPE) {
+				compressionType = param.getOutputFormatType();
 
 			} else {
 				List<String> supportedFormats =
-					ThumbnailatorUtils.getSupportedOutputFormatTypes(formatName);
-				
+						ThumbnailatorUtils.getSupportedOutputFormatTypes(formatName);
+
 				if (!supportedFormats.isEmpty()) {
-					writeParam.setCompressionType(supportedFormats.get(0));
+					compressionType = supportedFormats.get(0);
 				}
 			}
-	
+			if (compressionType != null) {
+				setCompressionModeExplicit(writeParam);
+				writeParam.setCompressionType(compressionType);
+			}
+
 			/*
 			 * Sets the compression quality, if specified.
-			 * 
+			 *
 			 * Note:
 			 * The value to denote that the codec's default compression quality
 			 * should be used is Float.NaN.
 			 */
-			if (!Float.isNaN(param.getOutputQuality())) {
+			if (param != null && !Float.isNaN(param.getOutputQuality())) {
+				setCompressionModeExplicit(writeParam);
 				writeParam.setCompressionQuality(param.getOutputQuality());
+
+			} else if (isPng(formatName) && isJava9OrNewer() && isDefaultPngWriter(writer)) {
+				/*
+				 * Before Java 9, the PNG writer bundled with the JRE was
+				 * using maximum compression.
+				 * To replicate the behavior in Java 9+, the compression
+				 * quality is set to 0.0f to trigger maximum compression.
+				 * See Issue #156: https://github.com/coobird/thumbnailator/issues/156
+				 */
+				setCompressionModeExplicit(writeParam);
+				writeParam.setCompressionQuality(0.0f);
 			}
 		}
-		
+
 		/*
 		 * The following line is not surrounded by a try-catch, as catching
 		 * the `IOException` and re-throwing would not give a good feedback as
@@ -187,11 +202,7 @@ public class OutputStreamImageSink extends AbstractImageSink<OutputStream> {
 		 * Also, the BMP writer appears not to support ARGB, so an RGB image
 		 * will be produced before saving.
 		 */
-		if (
-				formatName.equalsIgnoreCase("jpg")
-				|| formatName.equalsIgnoreCase("jpeg")
-				|| formatName.equalsIgnoreCase("bmp")
-		) {
+		if (isJpegOrBmp(formatName)) {
 			img = BufferedImages.copy(img, BufferedImage.TYPE_INT_RGB);
 		}
 		
@@ -212,6 +223,40 @@ public class OutputStreamImageSink extends AbstractImageSink<OutputStream> {
 		ios.close();
 	}
 
+	/**
+	 * Sets the compression mode to explicit, if not already.
+	 * A check exists to prevent setting the explicit mode more than once,
+	 * as any previously set parameters will be discarded.
+	 *
+	 * @param writeParam	Current image writer parameters.
+	 */
+	private void setCompressionModeExplicit(ImageWriteParam writeParam) {
+		if (writeParam.getCompressionMode() != ImageWriteParam.MODE_EXPLICIT) {
+			writeParam.setCompressionMode(ImageWriteParam.MODE_EXPLICIT);
+		}
+	}
+
+	private boolean isJpegOrBmp(String formatName) {
+		return formatName.equalsIgnoreCase("jpg")
+				|| formatName.equalsIgnoreCase("jpeg")
+				|| formatName.equalsIgnoreCase("bmp");
+	}
+
+	private boolean isPng(String formatName) {
+		return formatName.equalsIgnoreCase("png");
+	}
+
+	private boolean isDefaultPngWriter(ImageWriter writer) {
+		String writerClassName = writer.getClass().getName();
+		return "com.sun.imageio.plugins.png.PNGImageWriter".equals(writerClassName);
+	}
+
+	private boolean isJava9OrNewer() {
+		String version = System.getProperty("java.specification.version");
+		// Up to Java 8, specification version was 1.x.
+		return version != null && !version.contains(".");
+	}
+
 	public OutputStream getSink() {
 		return os;
 	}


=====================================
src/main/java/net/coobird/thumbnailator/util/ThumbnailatorUtils.java
=====================================
@@ -87,7 +87,8 @@ public final class ThumbnailatorUtils {
 	/**
 	 * Returns a {@link List} of supported output formats types for a specified
 	 * output format.
-	 * 
+	 *
+	 * @param format	The output format.
 	 * @return		A {@link List} of supported output formats types. If no
 	 * 				formats types are supported, or if compression is not
 	 * 				supported for the specified format, then an empty list


=====================================
src/test/java/net/coobird/thumbnailator/tasks/io/Issue156OutputStreamImageSinkTest.java
=====================================
@@ -0,0 +1,34 @@
+package net.coobird.thumbnailator.tasks.io;
+
+import net.coobird.thumbnailator.ThumbnailParameter;
+import net.coobird.thumbnailator.builders.ThumbnailParameterBuilder;
+import org.junit.Test;
+
+import javax.imageio.ImageIO;
+import java.awt.image.BufferedImage;
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.IOException;
+
+import static org.junit.Assert.assertTrue;
+
+public class Issue156OutputStreamImageSinkTest {
+	@Test
+	public void compressedPngDoesntGetLarger() throws IOException {
+		File originalFile = new File("src/test/resources/Exif/original.png");
+		BufferedImage originalImage = ImageIO.read(originalFile);
+
+		ByteArrayOutputStream baos = new ByteArrayOutputStream();
+		OutputStreamImageSink imageSink = new OutputStreamImageSink(baos);
+
+		ThumbnailParameter param = new ThumbnailParameterBuilder()
+				.scale(1.0)
+				.build();
+		imageSink.setThumbnailParameter(param);
+
+		imageSink.setOutputFormatName("png");
+		imageSink.write(originalImage);
+
+		assertTrue(baos.size() < originalFile.length());
+	}
+}



View it on GitLab: https://salsa.debian.org/java-team/libthumbnailator-java/-/compare/fc2f54cc5ae24692a8936de722720247950ecd81...8759988464589a00213a85dad8ba482088a7914f

-- 
View it on GitLab: https://salsa.debian.org/java-team/libthumbnailator-java/-/compare/fc2f54cc5ae24692a8936de722720247950ecd81...8759988464589a00213a85dad8ba482088a7914f
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/20211218/f935f7cc/attachment.htm>


More information about the pkg-java-commits mailing list