Comments (15)
As a workaround, I've used this:
BufferedImage originalImage = ImageIO.read(selectedFile);
int height = originalImage.getHeight();
int width = originalImage.getWidth();
// Conditional resize
if ((height > 500) || (width > 500)) {
Thumbnails.of(selectedFile).size(500, 500).toFile(thumb500File);
} else {
FileUtils.copyFile(selectedFile, thumb500File);
}
Original comment by [email protected]
on 14 May 2011 at 12:09
from thumbnailator.
Thank you for taking the time to file an issue and posting a workaround.
Currently, the back-end of Thumbnailator is undergoing design changes which
would allow for such a feature.
The changes are due to be part of the Thumbnailator 0.4.0 release, which I hope
to get out in a week or so.
The actual API might be something along the line of the following:
// Option 1
// Simply specifying the minimum dimensions
// *Actual method names are subject to further consideration
Thumbnails.of("path/to/image")
.size(200, 200)
.onlyIfLargerThan(200, 200)
.toFile("path/to/thumbnail")
// Option 2
// Building an expression to when to perform the resize.
// This would be more verbose, but could allow more flexible expressions for
// specifying when the resize should be performed.
// *Actual method names are subject to further consideration
Thumbnails.of("path/to/image")
.size(200, 200)
.onlyIf(Condition.widthLargerThan(200), Condition.HeightLargerThan(200))
.toFile("path/to/thumbnail")
I'd appreciate any input on other options and use cases for this issue.
I will be changing the ticket type to "Type-Enhancement" as this is a request
for a feature enhancement.
----------------------------------------
Note:
ImageMagick command-line option for specifying conditional resizing is listed
in the
section titled "Image Geometry" in the following URL:
* http://www.imagemagick.org/script/command-line-processing.php
Original comment by [email protected]
on 14 May 2011 at 1:05
- Changed state: Accepted
- Added labels: Type-Enhancement
- Removed labels: Type-Defect
from thumbnailator.
Original comment by [email protected]
on 14 May 2011 at 1:05
from thumbnailator.
Original comment by [email protected]
on 22 May 2011 at 2:44
- Changed state: Started
from thumbnailator.
what if image size is smaller than the given thumbnail size. is there any way
to convert that image in thumbnail size without any distortion or is there any
method for adding some background image around it and providing the same size
image.
Original comment by [email protected]
on 11 Jun 2011 at 9:31
from thumbnailator.
Original comment by [email protected]
on 28 Aug 2011 at 3:34
- Added labels: Milestone-0.4.0
from thumbnailator.
I don't think .onlyIfLargerThan(200, 200) is necessary, a boolean value for
onlyIfLargeThan is enough.
Original comment by [email protected]
on 17 Oct 2011 at 8:24
from thumbnailator.
Original comment by [email protected]
on 5 Feb 2012 at 8:12
- Added labels: Milestone-0.4.x
- Removed labels: Milestone-0.4.0
from thumbnailator.
hi,
is this option implemented yet (the last msg here is from feb 2012) or should i
use the workaround?
sincerely
Original comment by [email protected]
on 9 Dec 2013 at 1:36
from thumbnailator.
This feature is not implemented yet, and no real work has been performed on
this for the past couple of years.
So, at the moment, the workaround is the only option.
If you have any input about how this function should be implemented (in terms
of the API, as seen in comment #2), I'd be more than glad to hear them!
-----
Note: I'm changing the status, priority, and milestone to better reflect the
current status.
Original comment by [email protected]
on 9 Dec 2013 at 1:44
- Changed state: Accepted
- Added labels: Priority-Low
- Removed labels: Milestone-0.4.x, Priority-Medium
from thumbnailator.
Hi,
if I want to get image's height and weight
the only way is:
final Thumbnails.Builder<File> src = Thumbnails.of(srcImage);
final BufferedImage bufferedImage = src.asBufferedImage();
System.out.println(bufferedImage.getHeight());
System.out.println(bufferedImage.getWidth());
?
:)
Original comment by [email protected]
on 17 Jan 2014 at 5:42
from thumbnailator.
Oops, ran my code got one exception:
Exception in thread "main" java.lang.IllegalStateException: size is not set.
at net.coobird.thumbnailator.Thumbnails$Builder.checkReadiness(Unknown Source)
at net.coobird.thumbnailator.Thumbnails$Builder.asBufferedImage(Unknown Source)
seems I should call size method first
how can I resize image strategy?
I want to get original image's height and weight and compare with limit
and then resize the image
e.g., original image size is 200 * 400, max weight is 100
so the thumbnail size is 100 * 200
Original comment by [email protected]
on 17 Jan 2014 at 6:06
from thumbnailator.
Sorry for the wrong word 'weight' :)
it should be 'width'
Original comment by [email protected]
on 17 Jan 2014 at 6:09
from thumbnailator.
[deleted comment]
from thumbnailator.
Thumbnails.of(srcFile).width(maxWidth).toFiles(Rename.PREFIX_DOT_THUMBNAIL);
resolve the problem
Thanks for providing such awesome tool
Original comment by [email protected]
on 17 Jan 2014 at 6:13
from thumbnailator.
Related Issues (20)
- Watermark position incorrect for images re-oriented using EXIF metadata HOT 3
- Move to GitHub (and transition to a Git repository) HOT 5
- Change build from Ant to Maven HOT 4
- Google Project Hosting will drop support for Downloads HOT 3
- Using JAI library? HOT 1
- Thumbnailing problem for a specific JPEG image HOT 1
- OutOfMemoryError: Java heap space / Builder.asBufferedImage HOT 3
- Exception on opening nested folder HOT 5
- Recursively process images in nested directories
- Low quality when resizing a GIF image HOT 2
- Unexpected behaviour when using toFile without an extension matching output format HOT 1
- Support animated GIFs HOT 2
- Javadoc on Thumbnailator class has unclear remark on OutOfMemoryError HOT 3
- Implement a workaround for common OutOfMemoryError cases HOT 15
- java.lang.OutOfMemoryError: Java heap space after adding thumbnailator-feature-oom-workaround-SNAPSHOT.jar file HOT 6
- Please retain debug information in published JAR HOT 3
- forceSize Not maintaining the Aspect Ratio of thr original image HOT 5
- "Image cannot be null" when using `Thumbnails.of(BufferedImage...)` HOT 2
- Use embedded thumbnail from large JPEG images HOT 1
- SVG not supported
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from thumbnailator.