Function Repository Resource:

PinkBoxImageQ

Source Notebook

Determine whether an image contains a pink color typically created by an error in a notebook

Contributed by: Andy Hunt

ResourceFunction["PinkBoxImageQ"][source]

returns True if source image contains colors commonly found within ErrorBoxes.

Details and Options

In PinkBoxImageQ[source,…], source can be any of the following:
"file"file name, searched for on $Path
"url"HTTP, HTTPS or FTP URL
imgan Image object
The color associated with a pink error box is not the same color as Pink. This function will only look for error box colors.
ResourceFunction["PinkBoxImageQ"] supports the option ColorCoverage to specify the minimum pink box coverage to trigger a True result. The default value is 0.1.

Examples

Basic Examples (1) 

Return True if Image contains pink color from an ErrorBox:

In[1]:=
img = Rasterize@Cell[BoxData[FractionBox["1", "2", "3"]], "Output"]
Out[1]=
In[2]:=
ResourceFunction["PinkBoxImageQ"][img]
Out[2]=

Scope (2) 

Source can be an image:

In[3]:=
img = Rasterize@RawBoxes@Framed[x, FrameMargins -> Turtle]
Out[3]=
In[4]:=
Head@img
Out[4]=
In[5]:=
ResourceFunction["PinkBoxImageQ"][img]
Out[5]=

In addition to an Image, the source can be a URL for an image file:

In[6]:=
url = "https://wolfr.am/1sB4Jfxmo";
In[7]:=
Import[url]
Out[7]=
In[8]:=
ResourceFunction["PinkBoxImageQ"][url]
Out[8]=

Options (3) 

ColorCoverage (3) 

Create an image where a small portion is a pink box:

In[9]:=
errorBox = Rasterize@RawBoxes@Framed[x, FrameMargins -> Turtle]
Out[9]=
In[10]:=
img = Rasterize@
  Graphics[{Circle[], Inset[errorBox, {0, 0}, Automatic, 1]}]
Out[10]=

With the default coverage requirement, this gives False:

In[11]:=
ResourceFunction["PinkBoxImageQ"][img]
Out[11]=
In[12]:=
Options[ResourceFunction["PinkBoxImageQ"], ColorCoverage]
Out[12]=

Requiring a smaller coverage gives True:

In[13]:=
ResourceFunction["PinkBoxImageQ"][img, ColorCoverage -> 0.01]
Out[13]=

Publisher

Andy Hunt

Requirements

Wolfram Language 13.0 (December 2021) or above

Version History

  • 1.0.0 – 24 January 2025

License Information