Tag: imgscalr

使用Java和AsyncScalr缩放大图像

我在Servlet中使用AsyncScalr来缩小一些大图像(~10-15 MegaBytes),实际的大小调整过程大约需要40ms,这并不多。 过度杀伤来自将本地存储中的图像作为BufferedImage读取。 所以时间大多是: 读取图像文件:1630ms !! 调整图像大小:41ms写入图像:40ms 下面是我正在使用的代码,有没有更好的方法来做到这一点? final FileImageInputStream fileImageInputStream = new FileImageInputStream(file); BufferedImage bufferedImage = ImageIO.read(fileImageInputStream); // resize file Future result = AsyncScalr.resize(bufferedImage, Method.SPEED, width, OP_ANTIALIAS, OP_BRIGHTER); try { bufferedImage = result.get(); } catch (InterruptedException e) { e.printStackTrace(); } catch (ExecutionException e) { e.printStackTrace(); } // Write the image ImageIO.write(bufferedImage, imageOutput, outputStream);

通过摄像头拍照并以bytearray的forms发送到服务器

我正在开发一个Andorid应用程序,我想让用户拍照,然后保存它我将它发送到服务器。 现在,我将图片作为字节数组发送到服务器。 当我尝试将字节数组作为PNG文件保存到文件中,然后尝试打开文件时,图像查看器会抱怨PNG有错误并且无法显示。 PNG文件大小为122Kb。 当我尝试使用Scalr库来调整图像大小时,它表示图像源不能为空。 直接保存字节数会导致PNG损坏。 我应该如何将文件正确转换并发送到服务器,因此没有错误。 这是我正在使用并发送它的相机代码。 public class AddPhotoForUser extends DrawerLoader { private static final int CAMERA_PIC_REQUEST = 22; Button BtnSelectImage; private ImageView ImgPhoto; private static volatile Bitmap photo; private static volatile ByteArrayOutputStream stream = new ByteArrayOutputStream(); final PersonServiceImpl personService = new PersonServiceImpl(); private String[] navMenuTitles; private TypedArray navMenuIcons; @Override protected void onCreate(Bundle […]