# Image padding problem with transparent

I have an image that I'm trying to pad some transparent border. But I get error:

"The specified padding value is not compatible with a 3-channel image."

data = Table[{45, 45, 45}, {20}, {25}];
p = Image[RawArray["Byte", data], "Byte", Rule[ColorSpace, Automatic],
Rule[Interleaving, True]];



What does this error mean and how to solve it?

Update

If test on the documentation figure, padding transparent works even it has a Automatic color space:

• Is there a reason, why you are using Automatic for the ColorSpace? – Karsten 7. Sep 6 '14 at 17:02

You have to convert Transparent into, e.g., the RGB color space:

ImagePad[p, 10, ColorConvert[Transparent, "RGB"]]


This is due to the fact, that Transparent is GrayLevel[0,0] and is incompatible with the ImageColorSpace of your image p (Automatic, which means that no color space is specified).
You can also convert your image into a specific color space, e.g.

ImagePad[ColorConvert[p, "Grayscale"], 10, Transparent]

• Thanks for the asnwer, it's very helpful. I didn't know that the problem was from color space. TheAutomatic comes from importing a video. – xslittlegrass Sep 6 '14 at 18:00
• @xslittlegrass Its Automatic is different, as it has only one channel (use ImageChannels@p to check) compared to the 3 channels of your original p. – Karsten 7. Sep 9 '14 at 16:24