| | |
| | | import java.awt.image.BufferedImage;
|
| | | import java.io.File;
|
| | | import java.io.FileNotFoundException;
|
| | | import java.io.InputStream;
|
| | |
|
| | | import net.coobird.thumbnailator.Thumbnails;
|
| | | import net.coobird.thumbnailator.geometry.Positions;
|
| | |
| | | * @throws FileNotFoundException
|
| | | * @throws Exception
|
| | | */
|
| | | public static void centerCrop(File sourceImage, File destImage, float ratio)
|
| | | public static void centerCrop(InputStream sourceImage, File destImage, float ratio)
|
| | | throws FileNotFoundException, Exception {
|
| | | if (!sourceImage.exists())
|
| | | if (sourceImage==null)
|
| | | throw new FileNotFoundException();
|
| | | BufferedImage image = Thumbnails.of(sourceImage).scale(1.0f).asBufferedImage();
|
| | | int width = image.getWidth();
|