# Image background for cell?

I'd like to make code Cells have a specific background image. I know you can do this for Notebooks, but what about Cells?

This simple test fails:

ConvertImageToFullyScaledNinePatch[img_] :=
Module[{paddedImage = ImagePad[img, 1, Black]},
ReplaceImageValue[paddedImage,
Flatten[Outer[List, {0, #1}, {0, #2}] & @@
ImageDimensions[paddedImage], 1] -> White]];

img = ConvertImageToFullyScaledNinePatch[
ExampleData[{"TestImage", "JellyBeans"}]];

CellPrint@Cell["test", "Code", BackgroundAppearance -> img]

• Without a link to the earlier Q&A ConvertImageToFullyScaledNinePatch is without context so I added a link. I hope you don't mind. – Mr.Wizard May 20 '16 at 17:41
• Ah, I meant to include that, thanks! – M.R. May 20 '16 at 17:42

## 1 Answer

Probably not ideal, but using OverlayBox (undocumented) can get you something:

img = ConvertImageToFullyScaledNinePatch[
Import["https://addons.cdn.mozilla.net/static/img/docs/themes/header.jpg"]
];

CellPrint[
Cell[BoxData[
OverlayBox[{ToBoxes[img], "test"}, Alignment -> Center]], "Code",
CellFrameMargins -> 0, CellMargins -> 0, PageWidth -> 1600]]


• Since it is not editable anyway you can use documented Overlay. – Kuba May 20 '16 at 18:36
• @Kuba You are right of course, no need to get all complicated. – chuy May 20 '16 at 18:41
• in reflection this is kind of a bad solution, but maybe someone can use it find a better one. – chuy May 20 '16 at 22:09