Skip to main content

Comments

11 comments

  • Mordy Tikotzky

    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.

    3
  • Mordy Tikotzky

    Is there a way to trim but leave some padding.

    For example if an image has an extra 50px on each side. I would like to trim but leave 20px of space around the image.

    1
  • Matt Zisow

    I'm having the same problem. I'd like to trim out white space but make sure that it leaves at least a set number of pixels on each side of the object.

    1
  • Itay Taragano

    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

    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

    http://res.cloudinary.com/demo/image/upload/w_200,h_200,c_crop,g_face/e_trim/face_top.jpg

    0
  • Christopher O'Connor

    Thanks!

    Where is the documentation for e_trim, I can't find it?

    Is it only for white color?

    0
  • Itay Taragano

    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

    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

    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

    http://res.cloudinary.com/demo/image/upload/e_trim:20/face_left.jpg

    0
  • Dayson Pais

    How can I use e_trim in the PHP and jQuery libraries?

    0
  • Itay Taragano

    Hi Dayson, 

    Here are sample codes to deliver an image using the trim effect:

    In PHP:

    <?php echo cl_image_tag("sample.jpg", array("effect" => "trim")); ?>

    In jQuery:

    $.cloudinary.image("sample.jpg", { effect: "trim" });

    0
  • Pulkit Singhal

    Is it possible to give weights for top,bottom,left, right? Like e:trim:20:20:20:40

    0
  • Itay Taragano

    Thank you for your suggestion.

    While this is on our road-map to support in the future, there's no ETA yet.

    0
  • Itay Taragano

    You can accomplish that by adding a white border to the image, for example:

    http://res.cloudinary.com/demo/image/upload/w_200,h_200,c_crop,g_face/e_trim/bo_20px_solid_white/face_top.jpg



    For more information:

    http://cloudinary.com/blog/adding_borders_to_images

    -1

Post is closed for comments.