3

I'm trying to convert any picture to WebP on the fly but I have a lot of trouble with images that have a color space that isn't RGB: it's grayscale (kCGColorSpaceModelMonochrome).

Is there an existing WebP library or class that will convert non-RGB images to WebP? Or is there any way I can convert a non-RGB image to an RGB image programmatically so I can modify the WebP class that I already have?

Thanks!

viggity
  • 15,039
  • 7
  • 88
  • 96
Felix Lapalme
  • 1,058
  • 1
  • 11
  • 25
  • What colorspaces are you dealing with? Grayscale? HSV? Y'CbCr? CMYK? – user1118321 Jan 16 '14 at 02:54
  • @user1118321 I've had to deal with grayscale (kCGColorSpaceModelMonochrome) and RGB up to now. Converting a picture from grayscale to RGB shouldn't be complicated, right? – Felix Lapalme Jan 16 '14 at 16:52
  • No, not at all. If you have a bitmap of the grayscale image, you can just copy the grayscale value to all 3 channels (red, green, and blue) in a new bitmap and you'll have an RGB image that looks the same. – user1118321 Jan 16 '14 at 17:01
  • You are probably better off converting whatever you have (monochrome) into YUVA cause that was google's webp.framework converts to anyway. – Anton Tropashko Dec 30 '15 at 10:25
  • Actually that seems to apply only to the losy encoding path: // Main flag for encoder selecting between ARGB or YUV input. // It is recommended to use ARGB input (*argb, argb_stride) for lossless // compression, and YUV input (*y, *u, *v, etc.) for lossy compression // since these are the respective native colorspace for these formats. – Anton Tropashko Dec 30 '15 at 10:26

0 Answers0