\RequirePackage{keyval}
\RequirePackage{color,times,calc,graphicx}

\definecolor{gray10}{gray}{.9}
\definecolor{gray20}{gray}{.8}
\definecolor{gray30}{gray}{.7}
\definecolor{gray40}{gray}{.6}
\definecolor{gray50}{gray}{.5}
\define@key{cvpdf}{height}         {\cvpdfheight{#1}}
\define@key{cvpdf}{width}          {\cvpdfwidth{#1}}
\define@key{cvpdf}{background}     {\cvpdfbg{#1}}
\define@key{cvpdf}{backgroundcolor}{\cvpdfbgcolor{#1}}
\define@key{cvpdf}{rulesize}       {\cvpdfrulesize{#1}}
\define@key{cvpdf}{rulesep}        {\cvpdfrulesep{#1}}
\define@key{cvpdf}{align}          {\cvpdfalign{#1}}
\define@key{cvpdf}{framealign}     {\cvpdfframealign{#1}}
\define@key{cvpdf}{framecolor}     {\cvpdfframecolor{#1}}

\def\cvpdfheight#1{\gdef\@cvpdfheight{#1}}
    \let\@cvpdfheight=\@empty
\def\cvpdfwidth#1{\gdef\@cvpdfwidth{#1}}
\def\cvpdfbg#1{\gdef\@cvpdfbg{#1}}
\def\cvpdfbgcolor#1{\gdef\@cvpdfbgcolor{#1}}\cvpdfbgcolor{gray10}
\def\cvpdfframecolor#1{\gdef\@cvpdfrulecolor{\color{#1}}}\cvpdfframecolor{gray40}
\def\CVcolor{color}
\def\CVoverlay{overlay}
\def\cvpdfrulesize#1{\gdef\@cvpdfrulesize{#1}}\cvpdfrulesize{.2pt}
\def\cvpdfrulesep#1{\gdef\@cvpdfrulesep{#1}}\cvpdfrulesep{4pt}
\def\cvpdfalign#1{\gdef\@cvpdfalign{#1}}\cvpdfalign{c}
\def\cvpdfframealign#1{\gdef\@cvpdfframealign{#1}}\cvpdfframealign{t}

\def\framed{\@ifnextchar[{\@framed}{\@framed[]}}

\def\@framed[#1]#2{%
     \setkeys{cvpdf}{#1}
     \ifx\@cvpdfbg\CVcolor
     \ifx\@cvpdfheight\@empty
       \fboxsep=-.1pt
       \colorbox{\@cvpdfbgcolor}
        {\fboxsep=\@cvpdfrulesep
         \fboxrule=\@cvpdfrulesize
         \@cvpdfrulecolor
      \fbox{\parbox[\@cvpdfframealign]{\@cvpdfwidth}{\normalcolor#2}}}
     \else
       \fboxsep=-.1pt
       \colorbox{\@cvpdfbgcolor}
        {\fboxsep=\@cvpdfrulesep
         \fboxrule=\@cvpdfrulesize
         \@cvpdfrulecolor
      \fbox{\parbox[\@cvpdfframealign][\@cvpdfheight][\@cvpdfalign]
           {\@cvpdfwidth}{\normalcolor#2}}}
     \fi
     \else
     \ifx\@cvpdfbg\CVoverlay
        \fboxsep=\@cvpdfrulesep
        \fboxrule=\@cvpdfrulesize
       \setlength\frameoverlaywidth{\@cvpdfwidth}
       \setlength\frameoverlayheight{\@cvpdfheight}
       \setlength\CVframeOverlaywidth{\@cvpdfwidth}
       \addtolength\CVframeOverlaywidth{\@cvpdfrulesep}
       \addtolength\CVframeOverlaywidth{\@cvpdfrulesep}
       \addtolength\CVframeOverlaywidth{\@cvpdfrulesize}
       \addtolength\CVframeOverlaywidth{\@cvpdfrulesize}
       \addtolength\CVframeOverlaywidth{3pt}
         \color{white}
      \fbox{\parbox[t][\@cvpdfheight][t]
           {\@cvpdfwidth}
           {\CV@Overlay\rule{\frameoverlaywidth+\@cvpdfrulesep-2pt}{0pt}}}%
           \@cvpdfrulecolor
           \fboxrule=\@cvpdfrulesize
           \hspace*{-\CVframeOverlaywidth}
      \fbox{\parbox[t][\@cvpdfheight][\@cvpdfalign]
           {\@cvpdfwidth}
           {\normalcolor#2}}
     \fi\fi
}

\newdimen\frameoverlayheight
\newdimen\frameoverlaywidth
\newdimen\CVframeOverlaywidth

\def\frameoverlay#1{\gdef\@frameoverlay{#1}}\let\@frameoverlay\@empty
\def\CV@Overlay{\vbox to\z@{\hbox to\z@{%
        \includegraphics[width=\frameoverlaywidth,height=\frameoverlayheight]
         {\@frameoverlay}\hfill
         \hspace*{-\frameoverlaywidth}}
         \vfill
         \vspace*{-\frameoverlayheight}}}

\endinput


Example:

\usepackage{pdfoverlay}

\frameoverlay{am.jpg}      % if overlay specified in background

\framed[width=3in,         % widhth of the frame
        background=color,  % optional overlay
        backgroundcolor=gray10, % color of the background (use defined colors)
        framecolor=gray40,% color of the rule
        rulesize=0pt,     % thickness of the rule
        rulesep=0pt,      % sep space between rule and text/overlay
        height=1in,       % height of the box
        align=c]          % internal vertical alignment (t/b/c/s)
  {\centering\fontsize{20}{24}\selectfont
    This is nothing but a simple test}

%  usage \framed[options]{argument}
