Open thany opened 10 years ago
It would be relatively easy to implement for embedding the colorized image into CSS with a base64 encoding. You could probably do it yourself with a Ruby-backed Sass function leveraging MiniMagick.
Otherwise, you have to deal with saving generated images to disk, caching and maybe spriting. It's a lot more work.
Sounds like a great idea for an extension!
Sent from my iPhone
On May 15, 2014, at 11:30 AM, lolmaus notifications@github.com wrote:
It would be relatively easy to implement for embedding the colorized image into CSS with a base64 encoding. You could probably do it yourself with a Ruby-backed Sass function leveraging MiniMagick.
Otherwise, you have to deal with saving generated images to disk, caching and maybe spriting. It's a lot more work.
— Reply to this email directly or view it on GitHub.
I've gotten a base64 extension to work in the past, for inlining generated svg. But in this case, svg generating was nothing but string concatenation. I'm not familiar with minimagick... would it be able to do what I need? Or at least the colorizing part?
inline-image()
Sass function and it works both with bitmap and vector images. But it is only useful for fetching images from disk. If you're going to create a custom Sass function, you'll have to encode images yourself. It's not difficult, you can have a look how inline-image()
does it with Ruby.Here's my workflow to fetch icons from Fontello and embed them into CSS as colorized SVG images.
config.json
into your project root and rename it to fontello.json
.Here you can find all the code mentioned: https://gist.github.com/lolmaus/7ae7b1b51738a1b9a42e
The idea is that you'd have black&white images on disk, and have Compass colorize black pixels with a certain color value, leaving transparency intact. This would be very cool where css-generated images or svg are not an option, while still keeping the flexibility of being able to change colors.
The image would probably have to be included as a data-uri, which is fine.
So, for example, an image like this: Turned into this: By something like this:
Which would produce something like this:
Good idea?
I'm currently using 1.0.0.alpha.19 and I couldn't find a function quite like this, so I assumed it doesn't exist, therefore, a friendly suggestion ;)
(and yes, I know i could theoretically write an extension to do this, but ruby isn't exactly my kind of language atm)