Photoshop: Trim a photo so it contains no transparent pixels?

65,994

Solution 1

Image > Trim then select Based On: Transparent Pixels

Solution 2

Using CS6, the following does exactly what is required for me:

  1. select crop tool
  2. select 'straighten'
  3. draw along a known straight line
  4. the rotation is performed immediately and a suggested crop appears cutting out all the transparent pixels resulting from the rotation.

result: beautiful!

Solution 3

There are several different approaches I would take to this, but I can't think of a way to do it automatically.

First create a fill layer below with a bright colour. This shows you any semi-transparent pixels left from merging images.

Secondly, duplicate the top layer with your image. keep duplicating your original picture layer until any colour from the fill layer below has vanished. This has the effect of making any semi-transparent pixels completely opaque, and doesn't affect the rest of the image as it already is.

Last, merge all these layers and crop to the desired size. You could crop at the beginning if you wanted to, it makes no difference.

If a given pixel area has no fill, rather than crop it, why not clone over it with the clone tool?

Solution 4

Just in case photoshop does offer you no solution for this:

I use Microsoft ICE or Autopano Pro for photo stitching, and they both have very simple to use crop features to achieve just this.

Maybe you should try to use a different tool for stitching - ICE is free of charge, might be worth a try.

Solution 5

Make a new layer and Edit - Fill... it with black.

Now, with both layers visible and the picture layer selected, use Magic Wand, and with "Sample All Layers" and "Contiguous" checked, select the transparent area now turned black.

Hit delete. All contiguous transparent pixels should be deleted.

Share:
65,994

Related videos on Youtube

nickf
Author by

nickf

Javascript nerd. Senior Software Engineer at Google. Ex-SoundClouder.

Updated on September 17, 2022

Comments

  • nickf
    nickf almost 2 years

    In Photoshop, I've put together some panorama photos using the Photomerge tool, and the resulting image contains a lot of transparent pixels. Also, because it's assembled from multiple photos, the alignment can be off. What I'd like to do is cut the image down to the largest box which contains no transparent pixels at all. It's similar to the Trim tool, but this would remove a number of non-transparent pixels. Is there anything like this?

    Basically something that would automatically crop the above image to the selection box there: a rectangle with no transparent pixels.

    • jweede
      jweede almost 15 years
      Usually you can do a select-all on the layer and it will omit empty (transparent) pixels.
    • nickf
      nickf almost 15 years
      yes, but i want to trim it to a rectangle which doesn't contain transparent pixels. i'll edit to clarify that.
    • Aero Windwalker
      Aero Windwalker over 9 years
      You would imagine it's a simple feature but photoshop simply cannot do that without a script, and such script is easy to write - because you are basically looking for a biggest possible rectangle in the image based on current rotation. I will probably write one myself and share.
  • MT.
    MT. over 14 years
    I've found no good choice for stitching other than Photoshop. It's simply awesome... I opened 2 docs containing a scanned in image set a few settings in a dialog and let it work, perfectly stitched them together!
  • laurent
    laurent about 10 years
    That only works if the area to trim is rectangular. It won't work for arbitrary shapes like in the OP's example.
  • Aero Windwalker
    Aero Windwalker over 9 years
    This only works if the image is rectangular.
  • Scott - Слава Україні
    Scott - Слава Україні over 7 years
    I’ve never used Photoshop (and I don’t have it), so I can’t tell what this will do.  What does “deleting” a pixel do?  Will it delete non-transparent pixels?  (You do understand that the OP wants to crop the image, right?)  And P.S. Isn’t there a risk that black pixels that are legitimately part of the image might get thrown out with the bathwater?  P.P.S. You could improve your answer with illustrations; i.e., before and after images. P.P.P.S. Please do not respond in comments; edit your answer to make it clearer and more complete.
  • Etheryte
    Etheryte over 4 years
    While this might not be what the OP asked, this was exactly what I was looking for. Thanks!
  • Jeremiah
    Jeremiah over 2 years
    Not what was asked.