Ilkar
Ilkar

Reputation: 2177

Crop image in java with thumbnailator

I have picture which i want to crop, but i want to cut off onlu 100 px from the left of the picture.

I'm using thumbnailator.

Do you know maybe, how to do it?

Tanks

Upvotes: 3

Views: 3129

Answers (1)

Cleverson Sacramento
Cleverson Sacramento

Reputation: 363

It's easy. Just do this:

ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
Thumbnails.of(inputStream).crop(Positions.CENTER_LEFT).size(100,100).keepAspectRatio(true).toOutputStream(outputStream);
byte picture[] = outputStream.toByteArray();

Upvotes: 4

Related Questions