Trim method
AnsweredIs there a way to apply a trim filter to remove image border (like trim method in ImageMagick http://www.imagemagick.org/Usage/crop/#trim)
Thanks
-
Hi Christopher,
Cloudinary supports trimming white space around images using the 'trim' effect (
e_trim
).Here's an image example:
http://res.cloudinary.com/demo/image/upload/w_200,h_200,c_crop,g_face/face_top.jpg
And here's the same image using the 'trim' effect:
http://res.cloudinary.com/demo/image/upload/w_200,h_200,c_crop,g_face/e_trim/face_top.jpg
-
The 'trim' effect is a new feature that isn't documented yet, we're working hard on updating and improving our documentation.
The 'trim' effect will work on any color, it's using the background color of the corners of the image. In addition, you can add parameters to the 'trim' effect in order to control the tolerance for similar coloring (e.g.,
e_trim:40
).For example, here's an image:
http://res.cloudinary.com/demo/image/upload/face_left.jpg
Since the background isn't a solid color, the 'trim' effect won't make a difference:
http://res.cloudinary.com/demo/image/upload/e_trim/face_left.jpg
Setting the tolerance parameter to 20 (Default is 10) will make the difference:
http://res.cloudinary.com/demo/image/upload/e_trim:20/face_left.jpg
-
You can accomplish that by adding a white border to the image, for example:
For more information:
http://cloudinary.com/blog/adding_borders_to_images -
Thanks Itay, My Problem is that I have some photos with whitespace and some without.
What I'm trying to accomplish is that if a photo has whitespace then I want to trim the whitespace to 20px, but if the image does not currently have any whitespace then I dont want to add any additional whitespace. Is there anyway for me to accomplish that using cloudinary.
Post is closed for comments.
Comments
11 comments