input('site_id')) { $site = Site::where(['id' => $request->input('site_id')])->first(); } else { $site = $coupon->site()->first(); } $logo_display = $coupon->coupon_logo_image; $product_image = $coupon->coupon_decoration_image; // ---- Masque dans lequel l'image finale sera placée $mask = imagecreatefrompng($mask_img); list($maskWidth, $maskHeight) = getimagesize($mask_img); // ---- Contact distributeur $text = $coupon->coupon_site_contact; if (strlen($text) < 30) { $ImageFond = imagecreate(165, 27); $box1 = imagettfbbox(8, 0, $arial, $text); $white = imagecolorallocate($ImageFond, 255, 255, 255); $black = imagecolorallocate($ImageFond, 0, 0, 0); $this->imagettftextSp($ImageFond, 8, 0, 5, 23, $black, $arial, $text, 0.01); imagecolortransparent($ImageFond, $white); imagecopy($mask, $ImageFond, 743, 365, 0, 0, imagesx($ImageFond), imagesy($ImageFond)); } else { $ImageFond = imagecreate(195, 27); $box1 = imagettfbbox(7, 0, $arial, $text); $white = imagecolorallocate($ImageFond, 255, 255, 255); $black = imagecolorallocate($ImageFond, 0, 0, 0); $this->imagettftextSp($ImageFond, 7, 0, 5, 23, $black, $arial, $text, 0); imagecolortransparent($ImageFond, $white); imagecopy($mask, $ImageFond, 713, 365, 0, 0, imagesx($ImageFond), imagesy($ImageFond)); } // ----- Mentions légales + RCS if ($coupon->coupon_legal_mentions_splitted == 0) { $txt_mentions = $coupon->coupon_legal_mentions . " " . $coupon->coupon_rcs; $ImageMentionFond = imagecreate(415, 100); $boxMentions = imagettfbbox(7, 0, $arial, $txt_mentions); $white = imagecolorallocate($ImageMentionFond, 255, 255, 255); imagefilledrectangle($ImageMentionFond, 0, 0, 414, 99, $white); $black = imagecolorallocate($ImageMentionFond, 0, 0, 0); $lines_mentions = explode("\r\n", $txt_mentions); $y = 19; foreach ($lines_mentions as $line) { $this->imagettftextSp($ImageMentionFond, 7, 0, 15, $y, $black, $arial, $line, 0.01); $y = $y + 9; } // imagecolortransparent($ImageMentionFond, $white); imagecopy($mask, $ImageMentionFond, 335, 235, 0, 0, imagesx($ImageMentionFond), imagesy($ImageMentionFond)); } // ---- Copie la main dans le mask $hand = imagecreatefrompng($hand_picture); imagecopy($mask, $hand, 577, 2, 0, 0, imagesx($hand), imagesy($hand)); imagealphablending($mask, false); imagesavealpha($mask, true); // ---- Inscription du montant du BR $textMontant = number_format($coupon->coupon_value, 2, ",", " "); $textEuro = "€"; $libReduc = "DE RÉDUCTION IMMÉDIATE"; $ImageFond = imagecreate(265, 200); $white = imagecolorallocate($ImageFond, 255, 255, 255); $black = imagecolorallocate($ImageFond, 0, 0, 0); $blue = imagecolorallocate($ImageFond, 8, 169, 223); $grey = imagecolorallocate($ImageFond, 219, 219, 221); $this->imagettftext_contour($ImageFond, 95, 0, 5, 110, $grey, $impact, $textMontant, $blue, 3, 3, 3, 3); $this->imagettftext_contour($ImageFond, 50, 0, 220, 55, $grey, $arial, $textEuro, $blue, 2, 2, 2, 2); $this->imagettftext_contour($ImageFond, 16, 0, 0, 150, $grey, $impact, $libReduc, $blue, 1, 1, 1, 1); imagecolortransparent($ImageFond, $white); imagecopy($mask, $ImageFond, 360, 10, 0, 0, imagesx($ImageFond), imagesy($ImageFond)); // ---- Inscription filigramme $txt_filigramme = strtoupper($site->site_libelle) . " " . number_format($coupon->coupon_value, 2, ",", " ") . "€"; $line_filigramme = ""; $textFili = ""; for ($i = 0; $i < 11; $i++) { $line_filigramme .= $txt_filigramme . " "; } $line_filigramme .= "\r\n"; for ($i = 0; $i < 30; $i++) { $textFili .= $line_filigramme; } $textFiliLines = explode("\r\n", $textFili); $ImageFond = imagecreate(402, 240); $white = imagecolorallocate($ImageFond, 255, 255, 255); $blackOpac = imagecolorallocatealpha($ImageFond, 0, 0, 0, 20); $y = 0; foreach ($textFiliLines as $textFiliLine) { $y = $y + 20; $this->imagettftextSp($ImageFond, 11, 25, -100, $y, $black, $arial, $textFiliLine, 0.01); } // imagettftext($ImageFond , 11 , 25, -100, 11, $blackOpac, $arial, $textReduc); imagecolortransparent($ImageFond, $white); imagecopymerge($mask, $ImageFond, 349, 1, 0, 0, imagesx($ImageFond), imagesy($ImageFond), 30); // ---- Inscription produit valable $textReduc = $coupon->coupon_validity_text; if (strlen($textReduc) < 100) { $ImageFond = imagecreate(387, 200); $white = imagecolorallocate($ImageFond, 255, 255, 255); $black = imagecolorallocate($ImageFond, 0, 0, 0); $textReducs = explode("\r\n", $textReduc); $y = 14; foreach ($textReducs as $textReduc) { $this->imagettftextSp($ImageFond, 12, 0, 0, $y, $black, $arialbd, $textReduc, 0.01); $y = $y + 18; } imagecolortransparent($ImageFond, $white); imagecopy($mask, $ImageFond, 360, 170, 0, 0, imagesx($ImageFond), imagesy($ImageFond)); } elseif (strlen($textReduc) > 200) { $ImageFond = imagecreate(387, 205); $white = imagecolorallocate($ImageFond, 255, 255, 255); $black = imagecolorallocate($ImageFond, 0, 0, 0); $textReducs = explode("\r\n", $textReduc); $y = 10; foreach ($textReducs as $textReduc) { $this->imagettftextSp($ImageFond, 9, 0, 0, $y, $black, $arialbd, $textReduc, 0.01); $y = $y + 12; } imagecolortransparent($ImageFond, $white); imagecopy($mask, $ImageFond, 360, 165, 0, 0, imagesx($ImageFond), imagesy($ImageFond)); } else { $ImageFond = imagecreate(387, 200); $white = imagecolorallocate($ImageFond, 255, 255, 255); $black = imagecolorallocate($ImageFond, 0, 0, 0); $textReducs = explode("\r\n", $textReduc); $y = 14; foreach ($textReducs as $textReduc) { $this->imagettftextSp($ImageFond, 10, 0, 0, $y, $black, $arialbd, $textReduc, 0.01); $y = $y + 12; } imagecolortransparent($ImageFond, $white); imagecopy($mask, $ImageFond, 360, 170, 0, 0, imagesx($ImageFond), imagesy($ImageFond)); }//end if // imagettftext($ImageFond , 12 , 0, 0, 14, $black, $arialbd, $textReduc); // ---- Copie le produit dans le mask $size = getimagesize($product_image); switch ($size['mime']) { case 'image/jpeg': $pdt = imagecreatefromjpeg($product_image); break; case 'image/png': $pdt = imagecreatefrompng($product_image); break; } imagealphablending($mask, true); imagesavealpha($mask, true); imagecopy($mask, $pdt, 40, 10, 0, 0, imagesx($pdt), imagesy($pdt)); // ---- Copie le logo dans le mask $size_logo = getimagesize($logo_display); switch ($size_logo['mime']) { case 'image/jpeg': $logo = imagecreatefromjpeg($logo_display); break; case 'image/png': $logo = imagecreatefrompng($logo_display); break; } imagealphablending($mask, true); imagesavealpha($mask, true); imagecopy($mask, $logo, 767, 220, 0, 0, imagesx($logo), imagesy($logo)); // ---- Créer le fichier final imagepng($mask, storage_path('app/public/modelfiles/coupons') . "/" . $coupon->coupon_code . ".png", 9); // ---- Libère la mémoire associée aux images manipulées imagedestroy($logo); imagedestroy($pdt); imagedestroy($mask); return "storage/modelfiles/coupons/" . $coupon->coupon_code . ".png"; } function imagettftextSp($image, $size, $angle, $x, $y, $color, $font, $text, $spacing = 0) { if ($spacing == 0) { imagefttext($image, $size, $angle, $x, $y, $color, $font, $text); } else { $temp_x = $x; $temp_y = $y; // to avoid special char problems $char_array = preg_split('//u', $text, -1, PREG_SPLIT_NO_EMPTY); foreach ($char_array as $char) { imagefttext($image, $size, $angle, $temp_x, $temp_y, $color, $font, $char); $bbox = imagettfbbox($size, 0, $font, $char); $temp_x += cos(deg2rad($angle)) * ($spacing + ($bbox[2] - $bbox[0])); $temp_y -= sin(deg2rad($angle)) * ($spacing + ($bbox[2] - $bbox[0])); } } } function imagettftext_contour($image, $fontsize, $angle, $x, $y, $color, $font, $text, $color_contour, $contour_haut = 1, $contour_bas = 1, $contour_gauche = 1, $contour_droite = 1) { $coords_x = array(); $coords_y = array(); for ($i_y = -$contour_haut; $i_y <= $contour_bas; $i_y++) { $y_temp = @array_fill(0, $contour_gauche + $contour_droite + 1, $i_y); $x_temp = array(); for ($i_x = -$contour_gauche; $i_x <= $contour_droite; $i_x++) { $x_temp[] = $i_x; } $coords_x = array_merge($coords_x, $x_temp); $coords_y = array_merge($coords_y, $y_temp); } $c = count($coords_x); for ($i = 0; $i < $c; $i++) { imagettftext($image, $fontsize, $angle, $x + $coords_x[$i], $y + $coords_y[$i], $color_contour, $font, $text); } imagettftext($image, $fontsize, $angle, $x, $y, $color, $font, $text); } public function printCp($coupon, $contact) { $arial = public_path() . '/build/assets/fonts/coupons/arial.ttf'; $arialbd = public_path() . '/build/assets/fonts/coupons/arialbd.ttf'; // ---- Masque dans lequel l'image finale sera placée $mask = imagecreatefrompng($coupon->coupon_image); list($maskWidth, $maskHeight) = getimagesize($coupon->coupon_image); // ----- Mentions légales + RCS dépendant de l'user if ($coupon->coupon_legal_mentions_splitted == 1) { $legalMentions = explode('', $coupon->coupon_legal_mentions); if (($coupon->coupon_norme == 1 && strlen($contact->contact_cp) == 4) || $coupon->coupon_code == '5425003942648' || $coupon->coupon_code == '5425003941641') { // BELGE $txt_mentions = $legalMentions[0] . "\n\r" . $legalMentions[1] . " " . $coupon->coupon_rcs; $ImageMentionFond = imagecreate(420, 145); $boxMentions = imagettfbbox(7, 0, $arial, $txt_mentions); $white = imagecolorallocate($ImageMentionFond, 255, 255, 255); imagefilledrectangle($ImageMentionFond, 0, 0, 414, 99, $white); $black = imagecolorallocate($ImageMentionFond, 0, 0, 0); $lines_mentions = explode("\r\n", $txt_mentions); $y = 19; foreach ($lines_mentions as $line) { $this->imagettftextSp($ImageMentionFond, 7, 0, 15, $y, $black, $arial, $line, 0.01); $y = $y + 9; } // imagecolortransparent($ImageMentionFond, $white); imagecopy($mask, $ImageMentionFond, 335, 235, 0, 0, imagesx($ImageMentionFond), imagesy($ImageMentionFond)); } else { // FR $txt_mentions = $legalMentions[0] . " " . $coupon->coupon_rcs; $ImageMentionFond = imagecreate(415, 100); $boxMentions = imagettfbbox(7, 0, $arial, $txt_mentions); $white = imagecolorallocate($ImageMentionFond, 255, 255, 255); imagefilledrectangle($ImageMentionFond, 0, 0, 414, 99, $white); $black = imagecolorallocate($ImageMentionFond, 0, 0, 0); $lines_mentions = explode("\r\n", $txt_mentions); $y = 19; foreach ($lines_mentions as $line) { $this->imagettftextSp($ImageMentionFond, 7, 0, 15, $y, $black, $arial, $line, 0.01); $y = $y + 9; } // imagecolortransparent($ImageMentionFond, $white); imagecopy($mask, $ImageMentionFond, 335, 235, 0, 0, imagesx($ImageMentionFond), imagesy($ImageMentionFond)); }//end if }//end if // ---- Inscription de l'utilisateur et de la ville $libelle = "OFFRE RÉSERVÉE À"; $user = $contact->contact_prenom . " " . $contact->contact_nom . "\r\n" . $contact->contact_cp . " " . $contact->contact_ville; $ImageFond = imagecreate(120, 40); $white = imagecolorallocate($ImageFond, 255, 255, 255); $black = imagecolorallocate($ImageFond, 0, 0, 0); $box1 = imagettfbbox(8, 0, $arial, $user); $box2 = imagettfbbox(8, 0, $arial, $libelle); imagettftext($ImageFond, 8, 0, (120 / 2) - (abs($box2[4]) - abs($box2[6])) / 2, 10, $black, $arialbd, $libelle); imagettftext($ImageFond, 8, 0, (120 / 2) - (abs($box1[4]) - abs($box1[6])) / 2, 25, $black, $arial, $user); imagecolortransparent($ImageFond, $white); imagecopy($mask, $ImageFond, 770, 50, 0, 0, imagesx($ImageFond), imagesy($ImageFond)); // ---- Inscription de la date de validité $libelle = "Valable jusqu'au :"; if ($coupon->coupon_validity != 0) { $dateValidite = date('d/m/Y', strtotime("+" . $coupon->coupon_validity . " day")); } else { $dateValidite = date('d/m/Y', strtotime("+30 day")); // 30 jours par défaut } $ImageFond = imagecreate(120, 40); $white = imagecolorallocate($ImageFond, 255, 255, 255); $black = imagecolorallocate($ImageFond, 0, 0, 0); imagettftext($ImageFond, 8, 0, 1, 8, $black, $arialbd, $libelle); imagettftext($ImageFond, 8, 0, 20, 23, $black, $arial, $dateValidite); imagecolortransparent($ImageFond, $white); imagecopy($mask, $ImageFond, 780, 142, 0, 0, imagesx($ImageFond), imagesy($ImageFond)); // ---- Création code barre if (($coupon->coupon_norme == 1 && strlen($contact->contact_cp) == 4) || $coupon->coupon_code == '5425003942648' || $coupon->coupon_code == '5425003941641') { $textReduc = "Traitement ScanCoupon/HighCo Data Benelux"; } elseif ($coupon->coupon_treatment_center == 0) { $textReduc = "• Traitement ScanCoupon •"; } else { $textReduc = "• Traitement Sogec •"; } $ImageFond = imagecreate(270, 20); $white = imagecolorallocate($ImageFond, 255, 255, 255); $black = imagecolorallocate($ImageFond, 0, 0, 0); imagettftext($ImageFond, 9, 0, 0, 10, $black, $arialbd, $textReduc); if (($coupon->coupon_norme == 1 && strlen($contact->contact_cp) == 4) || $coupon->coupon_code == '5425003942648' || $coupon->coupon_code == '5425003941641') { imagecopy($mask, $ImageFond, 70, 230, 0, 0, imagesx($ImageFond), imagesy($ImageFond)); } else { imagecopy($mask, $ImageFond, 52, 322, 0, 0, imagesx($ImageFond), imagesy($ImageFond)); } if (($coupon->coupon_norme == 1 && strlen($contact->contact_cp) == 4) || $coupon->coupon_code == '5425003942648' || $coupon->coupon_code == '5425003941641') { $codeBarre = imagecreatefromjpeg($coupon->coupon_gs1code); imageresolution($codeBarre, 72); list($width, $height) = getimagesize($coupon->coupon_gs1code); $r = $width / $height; $w = 285; $h = 150; if ($w / $h > $r) { $newwidth = $h * $r; $newheight = $h; } else { $newheight = $w / $r; $newwidth = $w; } $test = imagecreatetruecolor($newwidth, $newheight); imagecopyresampled($test, $codeBarre, 0, 0, 0, 0, $newwidth, $newheight, $width, $height); imagecopy($mask, $test, 60, 250, 0, 0, imagesx($test), imagesy($test)); } else { $codeBarre = $coupon->coupon_code . strtoupper($contact->contact_id); $codeBarrePrint = $codeBarre; $generator = new \Picqer\Barcode\BarcodeGeneratorPNG(); $base64 = $generator->getBarcode($codeBarrePrint, $generator::TYPE_CODE_128_A, 2, 46); $barcodeImage = imagecreatefromstring($base64); imagecopy($mask, $barcodeImage, 52, 342, 0, 0, imagesx($barcodeImage), imagesy($barcodeImage)); $ImageFond = imagecreate(380, 15); $white = imagecolorallocate($ImageFond, 255, 255, 255); $black = imagecolorallocate($ImageFond, 0, 0, 0); imagettftext($ImageFond, 11, 0, 0, 14, $black, $arial, $codeBarre); imagecopy($mask, $ImageFond, 52, 390, 0, 0, imagesx($ImageFond), imagesy($ImageFond)); }//end if ob_start(); imagejpeg($mask, null, 100); $contents = ob_get_contents(); ob_end_clean(); $dataUri = "data:image/jpeg;base64," . base64_encode($contents); // ---- Libère la mémoire associée aux images manipulées imagedestroy($mask); imagedestroy($ImageFond); return $dataUri; } // VB 22/04/2021 public function printCoupon(Coupon $coupon, Customers $customer, $crmInfos) { $arial = public_path() . '/build/assets/fonts/coupons/arial.ttf'; $arialbd = public_path() . '/build/assets/fonts/coupons/arialbd.ttf'; // ---- Masque dans lequel l'image finale sera placée $mask = imagecreatefrompng($coupon->coupon_image); list($maskWidth, $maskHeight) = getimagesize($coupon->coupon_image); // ----- Mentions légales + RCS dépendant de l'user if ($coupon->coupon_legal_mentions_splitted == 1) { $legalMentions = explode('', $coupon->coupon_legal_mentions); if ($customer->country !== 250) { // BELGIQUE - Luxembourg $txt_mentions = $legalMentions[0] . "\n\r" . $legalMentions[1] . " " . $coupon->coupon_rcs; $ImageMentionFond = imagecreate(420, 145); $boxMentions = imagettfbbox(7, 0, $arial, $txt_mentions); $white = imagecolorallocate($ImageMentionFond, 255, 255, 255); imagefilledrectangle($ImageMentionFond, 0, 0, 414, 99, $white); $black = imagecolorallocate($ImageMentionFond, 0, 0, 0); $lines_mentions = explode("\r\n", $txt_mentions); $y = 19; foreach ($lines_mentions as $line) { $this->imagettftextSp($ImageMentionFond, 7, 0, 15, $y, $black, $arial, $line, 0.01); $y = $y + 9; } // imagecolortransparent($ImageMentionFond, $white); imagecopy($mask, $ImageMentionFond, 335, 235, 0, 0, imagesx($ImageMentionFond), imagesy($ImageMentionFond)); } else { // FR $txt_mentions = $legalMentions[0] . " " . $coupon->coupon_rcs; $ImageMentionFond = imagecreate(415, 100); $boxMentions = imagettfbbox(7, 0, $arial, $txt_mentions); $white = imagecolorallocate($ImageMentionFond, 255, 255, 255); imagefilledrectangle($ImageMentionFond, 0, 0, 414, 99, $white); $black = imagecolorallocate($ImageMentionFond, 0, 0, 0); $lines_mentions = explode("\r\n", $txt_mentions); $y = 19; foreach ($lines_mentions as $line) { $this->imagettftextSp($ImageMentionFond, 7, 0, 15, $y, $black, $arial, $line, 0.01); $y = $y + 9; } // imagecolortransparent($ImageMentionFond, $white); imagecopy($mask, $ImageMentionFond, 335, 235, 0, 0, imagesx($ImageMentionFond), imagesy($ImageMentionFond)); }//end if }//end if // ---- Inscription de l'utilisateur et de la ville $libelle = "OFFRE RÉSERVÉE À"; $user = $crmInfos->firstname . " " . $crmInfos->lastname . "\r\n" . $crmInfos->postcode . " " . $crmInfos->city; $ImageFond = imagecreate(120, 40); $white = imagecolorallocate($ImageFond, 255, 255, 255); $black = imagecolorallocate($ImageFond, 0, 0, 0); $box1 = imagettfbbox(8, 0, $arial, $user); $box2 = imagettfbbox(8, 0, $arial, $libelle); imagettftext($ImageFond, 8, 0, (120 / 2) - (abs($box2[4]) - abs($box2[6])) / 2, 10, $black, $arialbd, $libelle); imagettftext($ImageFond, 8, 0, (120 / 2) - (abs($box1[4]) - abs($box1[6])) / 2, 25, $black, $arial, $user); imagecolortransparent($ImageFond, $white); imagecopy($mask, $ImageFond, 770, 50, 0, 0, imagesx($ImageFond), imagesy($ImageFond)); // ---- Inscription de la date de validité $libelle = "Valable jusqu'au :"; if ($coupon->coupon_validity != 0) { $dateValidite = date('d/m/Y', strtotime("+" . $coupon->coupon_validity . " day")); } else { $dateValidite = date('d/m/Y', strtotime("+30 day")); // 30 jours par défaut } $ImageFond = imagecreate(120, 40); $white = imagecolorallocate($ImageFond, 255, 255, 255); $black = imagecolorallocate($ImageFond, 0, 0, 0); imagettftext($ImageFond, 8, 0, 1, 8, $black, $arialbd, $libelle); imagettftext($ImageFond, 8, 0, 20, 23, $black, $arial, $dateValidite); imagecolortransparent($ImageFond, $white); imagecopy($mask, $ImageFond, 780, 142, 0, 0, imagesx($ImageFond), imagesy($ImageFond)); // ---- Création code barre if ($customer->country !== 250) { $textReduc = "Traitement ScanCoupon/HighCo Data Benelux"; } elseif ($coupon->coupon_treatment_center == 0) { $textReduc = "• Traitement ScanCoupon •"; } else { $textReduc = "• Traitement Sogec •"; } $ImageFond = imagecreate(270, 20); $white = imagecolorallocate($ImageFond, 255, 255, 255); $black = imagecolorallocate($ImageFond, 0, 0, 0); imagettftext($ImageFond, 9, 0, 0, 10, $black, $arialbd, $textReduc); if ($customer->country !== 250) { imagecopy($mask, $ImageFond, 70, 230, 0, 0, imagesx($ImageFond), imagesy($ImageFond)); } else { imagecopy($mask, $ImageFond, 52, 322, 0, 0, imagesx($ImageFond), imagesy($ImageFond)); } if ($customer->country !== 250) { $codeBarre = imagecreatefromjpeg($coupon->coupon_gs1code); imageresolution($codeBarre, 72); list($width, $height) = getimagesize($coupon->coupon_gs1code); $r = $width / $height; $w = 285; $h = 150; if ($w / $h > $r) { $newwidth = $h * $r; $newheight = $h; } else { $newheight = $w / $r; $newwidth = $w; } $test = imagecreatetruecolor($newwidth, $newheight); imagecopyresampled($test, $codeBarre, 0, 0, 0, 0, $newwidth, $newheight, $width, $height); imagecopy($mask, $test, 60, 250, 0, 0, imagesx($test), imagesy($test)); } else { $codeBarre = $coupon->coupon_code . strtoupper($customer->crm_id); $codeBarrePrint = $codeBarre; if (strpos($customer->crm_id, "@") !== false) { $codeBarre = $coupon->coupon_code . strtolower($customer->crm_id); $codeBarrePrint = $coupon->coupon_code . ".@."; } $generator = new \Picqer\Barcode\BarcodeGeneratorPNG(); $base64 = $generator->getBarcode($codeBarrePrint, $generator::TYPE_CODE_128_A, 2, 46); $barcodeImage = imagecreatefromstring($base64); imagecopy($mask, $barcodeImage, 52, 342, 0, 0, imagesx($barcodeImage), imagesy($barcodeImage)); $ImageFond = imagecreate(380, 15); $white = imagecolorallocate($ImageFond, 255, 255, 255); $black = imagecolorallocate($ImageFond, 0, 0, 0); imagettftext($ImageFond, 11, 0, 0, 14, $black, $arial, $codeBarre); imagecopy($mask, $ImageFond, 52, 390, 0, 0, imagesx($ImageFond), imagesy($ImageFond)); }//end if ob_start(); imagejpeg($mask, null, 100); $contents = ob_get_contents(); ob_end_clean(); $dataUri = "data:image/jpeg;base64," . base64_encode($contents); // ---- Libère la mémoire associée aux images manipulées imagedestroy($mask); imagedestroy($ImageFond); return $dataUri; } }