Gregwar / Image

A PHP library to handle images
MIT License
1k stars 191 forks source link

Combine multiple images / Sprite #72

Closed garygreen closed 9 years ago

garygreen commented 9 years ago

Is this possible? For instance, creating a sprite from multiple images to save on HTTP requests.

Gregwar commented 9 years ago

I don't understand what you want to do Maybe you're talking of merge ()?

garygreen commented 9 years ago

For instance like https://github.com/Ensighten/grunt-spritesmith

Interesting, I didn't see merge before. It's not quite what I'm after as with this it seems you need to pass x, y, width, height, i was looking for more an automatic method for combing multiple images maybe one on-top of another. Have you seen the CSS Sprite technique? That's primary reason for wanting this

garygreen commented 9 years ago

I supose thinking about it you would need a way of generating a CSS file as well with the x, y start coordinates for the merged/combined images, or at least a dedicated method that will return a keyed-filename array with the coordinates like:

$coordinates = Gregwar::createSprite('file1.jpg', 'file2.jpg');

'file1.jpg' => [0, 0],
'file2.jpg' => [0, 300]

Probably outside scope of this package itself though.

Gregwar commented 9 years ago

Indeed, but it's not a really hard problem though

I think there is already scripts to do this specifically