Page 1 of 1

[SOLVED] cropping sprites

Posted: 16 June 2018, 17:11
by apollo1001
Hi All

I'm currently using a sprite of tiles which are a little large (essentially they have still got their bleed areas). I am able to use CSS to crop the outer 7px from around each tile without any issue, but I'm now wondering about using the Stock component to hold a selection of these tiles. To my knowledge the Stock component doesn't have any options to crop / offset / resize the images but simply carves up the sprite into the fixed size pieces.

So my question is: what is the easiest way to get my sprite file to work with the stock component? Currently the only way I can think of doing it is to crop each individual tile and rebuild the overall sprite. If anyone has used any clever sprite software or knows a way of setting this up with Stock then I'd welcome the advise!

For clarity all of my tile images are currently 7px too big in each direction and need cropping, not resizing.

Thanks
Apollo

Re: cropping sprites

Posted: 16 June 2018, 21:17
by Woodruff
Hi!

If you know the Python language, you can use the PIL library (Picture Image Library, Pillow in Python 3), to process your file programmatically:
https://pillow.readthedocs.io/en/5.1.x/
The idea is to loop on each card of your sprite, crop it and bundle them together again.
I think such utility exists in another language you'd like more.

Tcheby

Re: cropping sprites

Posted: 17 June 2018, 12:47
by apollo1001
Tchebychev wrote:process your file programmatically
Thank you Tcheby. Not sure why I hadn't thought of that in the first place! :lol:

Re: [SOLVED] cropping sprites

Posted: 17 June 2018, 17:51
by Woodruff
My pleasure :)
Enjoy!

Re: [SOLVED] cropping sprites

Posted: 17 June 2018, 19:30
by Victoria_La
The imagemagic (command line image manipulation utils) have bunch of options of cropping/stitching/resizing/converting images.
I never had to do anything programmatically because it so reach. Do you have images before they got into sprite?