Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for image cliping #6

Closed
GoogleCodeExporter opened this issue Jul 25, 2015 · 7 comments
Closed

Add support for image cliping #6

GoogleCodeExporter opened this issue Jul 25, 2015 · 7 comments

Comments

@GoogleCodeExporter
Copy link

Sometimes people want images to be thumbnailed within a range. Maybe it's 
better to offer a way to thumbnail a picture by its x&y coordinates.
If clip is being implemented by you, then I just need sit down and wait. If 
not, maybe I will implement it by myself and post it later.

Original issue reported on code.google.com by lamusico...@gmail.com on 27 Mar 2011 at 1:46

@GoogleCodeExporter
Copy link
Author

Hello!

Thank you for your suggestion.

I've received a request for a similar feature via e-mail from another user of 
Thumbnailator, so I think there is a real need for this feature.

Currently, Thumbnailator allows *post*-processing of thumbnails, but no 
*pre*-processing (such as cropping) of the original image before the image is 
resized.

Therefore, I'll definitely look into implementing this feature, probably in 
early April.

Any feedback on specific use cases are greatly welcome.

Chris

---

P.S. Thumbnailator 0.3.2 has introduced the `Canvas` image filter 
(http://thumbnailator.googlecode.com/hg/javadoc/net/coobird/thumbnailator/filter
s/Canvas.html) which will allow the thumbnail to be cropped.

However, as mentioned earlier, this affects the *thumbnail* -- the cropping 
takes effect on the thumbnail, not the original image.

P.P.S I'm going to reclassify this as a "Type-Enhancement" to reflect the type 
of issue this is.

Original comment by coobird...@gmail.com on 29 Mar 2011 at 4:01

  • Changed state: Accepted
  • Added labels: Type-Enhancement
  • Removed labels: Type-Defect

@GoogleCodeExporter
Copy link
Author

Very much looking forward!
this feature is useful for me.

Original comment by im.tao...@gmail.com on 31 Mar 2011 at 4:29

@GoogleCodeExporter
Copy link
Author

I want download an original image and add my logo
The feature is what i'm looking for. :D

Original comment by tk1c...@gmail.com on 8 Apr 2011 at 3:33

@GoogleCodeExporter
Copy link
Author

Work has commenced on a feature to be able to specify the region of the source 
image to use when creating a thumbnail.

For example, creating a 200x200 thumbnail from the center 400x400 region of the 
source image could be written like the following*:

  Thumbnails.of("/path/to/image")
    .sourceRegion(Positions.CENTER, 400, 400)
    .size(200, 200)
    .toFile("/path/to/thumbnail")

* Final APIs are subject to change.

The work is underway in the `source-region` branch:
http://code.google.com/p/thumbnailator/source/browse/?r=source-region

Original comment by coobird...@gmail.com on 23 Apr 2011 at 6:20

  • Changed state: Started

@GoogleCodeExporter
Copy link
Author

A new feature enhancement has been released as part of Thumbnailator 0.3.4.

Now it is possible to specify the source region to use when creating a 
thumbnail through the `Thumbnails` fluent interface.

The example shown in Comment 4 is now possible, along with a few more options 
for specifying the size and position.

For more information, please refer to the "Changes" for 0.3.4:
http://code.google.com/p/thumbnailator/wiki/Changes#Thumbnailator_0.3.4_%28May_3
,_2011%29

Original comment by coobird...@gmail.com on 3 May 2011 at 12:17

  • Changed state: Fixed

@GoogleCodeExporter
Copy link
Author

Since you don't mention that it is an error, I presume that the source region 
can be bigger than the image. When this is the case how do you specify the 
colour used the pad the source image?

Original comment by slp1...@gmail.com on 15 Jun 2011 at 10:46

@GoogleCodeExporter
Copy link
Author

Hello slp1...@gmail.com,

Indeed, it is not an error to specify a source region that is larger than the 
original image.

I realize that the `sourceRegion(...)` method is poorly documented, but the 
behavior for this scenario is that the region outside of the original image 
will simply be ignored -- in essence the final source image region is an 
intersection of the original image size and the specified source region.

For example, if the original was 200x200, and the source region was 400x400 at 
(0,0), the resulting image will be 200x200.

This behavior was specified this in the back-end processing class 
(`Region.calculate` - 
http://thumbnailator.googlecode.com/hg/javadoc/net/coobird/thumbnailator/geometr
y/Region.html#calculate(int,%20int)), but neglected to include the details in 
the `sourceRegion` method; I'll be sure to document this in the next release.

The answer to the final question is, there isn't a way to specify the padding 
color, as the current behavior does not perform padding.

If a feature to pad the source region outside of the original image is a 
feature that is needed, please file a new issue for a feature enhancement. (Or 
let me know and I'll add one when I get a little more free time.)

Thanks!

Original comment by coobird...@gmail.com on 15 Jun 2011 at 2:11

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant