Package org.forgerock.doc.maven.utils
Class PngUtils
java.lang.Object
org.forgerock.doc.maven.utils.PngUtils
Set dots per inch in the metadata of a Portable Network Graphics image.
-
Method Summary
Modifier and TypeMethodDescriptionstatic BufferedImage
getScaledInstance
(BufferedImage img, int targetWidth, int targetHeight, Object hint, boolean higherQuality) Convenience method that returns a scaled instance of the providedBufferedImage
.static void
Creates a thumbnail copy of provided image, prefixed with "thumb_".static void
Set the DPI onimage
to 160.static void
Set the DPI onimage
todotsPerInch
.static void
setSafeDpi
(File image, int maxHeightInInches) Set the DPI onimage
so that it fits inmaxHeightInInches
, or to 160 if short enough.
-
Method Details
-
resizePng
Creates a thumbnail copy of provided image, prefixed with "thumb_".- Parameters:
image
- image file.- Throws:
IOException
- Failed to read the image or to write the thumbnail.
-
getScaledInstance
public static BufferedImage getScaledInstance(BufferedImage img, int targetWidth, int targetHeight, Object hint, boolean higherQuality) Convenience method that returns a scaled instance of the providedBufferedImage
.- Parameters:
img
- the original image to be scaledtargetWidth
- the desired width of the scaled instance, in pixelstargetHeight
- the desired height of the scaled instance, in pixelshint
- one of the rendering hints that corresponds toRenderingHints.KEY_INTERPOLATION
(e.g.RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR
,RenderingHints.VALUE_INTERPOLATION_BILINEAR
,RenderingHints.VALUE_INTERPOLATION_BICUBIC
)higherQuality
- if true, this method will use a multi-step scaling technique that provides higher quality than the usual one-step technique (only useful in downscaling cases, wheretargetWidth
ortargetHeight
is smaller than the original dimensions, and generally only when theBILINEAR
hint is specified)- Returns:
- a scaled version of the original
BufferedImage
-
setSafeDpi
Set the DPI onimage
so that it fits inmaxHeightInInches
, or to 160 if short enough.- Parameters:
image
- PNG image file.maxHeightInInches
- maximum available image height in inches.- Throws:
IOException
- Failed to save the image.
-
setDpi
Set the DPI onimage
to 160.- Parameters:
image
- PNG image file.- Throws:
IOException
- Failed to save the image.
-
setDpi
Set the DPI onimage
todotsPerInch
.- Parameters:
image
- PNG image file.dotsPerInch
- DPI to set in metadata.- Throws:
IOException
- Failed to save the image.
-