First of all i want to say that Jimp is awesome really its much needed addition to nodejs libs 馃憤 but i having a little confusion that when i create a new image
var jimp = new Jimp(1200, 600, 0x00FF0000, cb);,
and i want to set image background i had to pass javascript octa numerals i want to ask is there any way to pass color string or hex code? if not then it would be awesome for future releases!
and weird thing is if i try to pass let suppose pink color
as Pink hex is ffc0cb
i pass 0xFFffc0cb
but its giving me yellowish color!!
may be i dont know how it works so its happening so kindly help :) thanks
Hi.
It's RGBA, not ARGB, so your code should look like this
var img = new Jimp(1200, 600, 0xFFC0CBFF);
If you want to use strings with HEX codes, rgb()/rgba()/hsl()/hsla()/hsv() notations or literals like "crimson", "gold", etc. I would suggest using "tinycolor2" module. My helper function looks something like this:
var TinyColor = require('tinycolor2');
function arbitraryColorToInt (val) {
val = val || 0; // 0, null, undefined, NaN
if (typeof val === 'number')
return Number(val);
var color = new TinyColor(val);
return parseInt(color.toHex8(), 16);
}
awesome will check when in home 馃憤
hey @Iwasawafag i passed #fff000 and it ruterns 255 i want to send it hex and then get RGBA which jimp can understand?
Perhaps you did something wrong. Here's the live demo: https://runkit.com/iwasawafag/588d0fc1a5de05001522146f
Thank you so much @Iwasawafag i just cant thank u :)
Most helpful comment
Hi.
It's RGBA, not ARGB, so your code should look like this
If you want to use strings with HEX codes, rgb()/rgba()/hsl()/hsla()/hsv() notations or literals like "crimson", "gold", etc. I would suggest using "tinycolor2" module. My helper function looks something like this: