Monday, April 25, 2011

What is the best way to crop an image in HTML?

What is the best way to crop an image in HTML?

It would be something like the following:

<img src="something.gif" x1="10" y1="10" x2="20" y2="20">

If that doesn't work, then I'll just use GIMP. Any thoughts on how I can get this to work programmatically?

From stackoverflow
  • That's called sprites, you can read this fantastic article of A List Apart.

    In the end it boils down to:

    #panel2b {
        width:50px;
        height:30px;
        background: transparent url(test-3.jpg) -96px -200px no-repeat;
    }
    
    Ólafur Waage : You need a height & width definition for that panel for it to work.
    Itay Moav : Ahhh sprites, reminds me the good days when I painted sprites in C64 with bytes representation...
  • You can also use a tool like this web based CSS Sprite Generator to create a larger image if you have many slices.

    [Someone on my similar question led me to yours].

0 comments:

Post a Comment

Note: Only a member of this blog may post a comment.