This is my controller:
 public function actionFind($id, $c, $t, $width = false, $height = false)
      {
        $image = \app\models\Picture::finding($id, $c, $t, $width, $height);
        \Yii::$app->response->format = yii\web\Response::FORMAT_RAW;
        \Yii::$app->response->headers->add('content-type', 'image/jpeg');
        \Yii::$app->response->data = file_get_contents($image);
        return \Yii::$app->response;
        }
This is my model:
public static function finding($id, $c, $t, $width = false, $height = false)
        {
        $query = new Query;
        // compose the query
        $query->select('*')
                ->from($t)
                ->where("Active=1 AND Code = $id")
                ->limit(1);
        $query->orderBy('Code desc');
        // build and execute the query
        $rows = $query->all();
        // alternatively, you can create DB command and execute it
        $command = $query->createCommand();
        // $command->sql returns the actual SQL
        $rows = $command->queryAll();
        if (isset($rows[0]["$c"]))
            {
            return $image = "data:image/jpeg;base64," . base64_encode($rows[0]["$c"]);
            }
        }
and this is my error:
cannot be displayed because it contains an error
my image save in database!!
Picture : longblob
in another project with database this code is run correct:
header("Content-Type: image/jpeg");
if (strlen($image) == 0 || $id == "")
    {
    if (!$w)
        $w = $w1;
    if (!$h)
        $h = $h1;
    if (!$w)
        $w = 120;
    if (!$h)
        $h = 140;
    $dst = imagecreatetruecolor($w, $h);
    $gray = imagecolorallocate($dst, 255, 255, 255);
    imagefill($dst, 1, 1, $gray);
    if ($q)
        imagejpeg($dst, NULL, $q);
    else
        imagejpeg($dst);
    }
 
     
    