<?php
require('USPSLabel.php');
function getuspsShippingLabel($sender, $recipient,$uspsSettings){

$labelImage = "";
$USPSResponse = USPSLabel($sender, $recipient,$uspsSettings);
if(is_array($USPSResponse) && count($USPSResponse) > 0){
$USPSLabel = $USPSResponse['DeliveryConfirmationV3.0Response']['DeliveryConfirmationLabel']['VALUE'];
if(count($array['DeliveryConfirmationV3.0Response']))
{
$confirmation_number = $array['DeliveryConfirmationV3.0Response'][0]['DELIVERYCONFIRMATIONLABEL'][0]['VALUE'];
$tif = base64_decode($confirmation_number);
// Create Imagick object
        $im = new Imagick();

       // Convert image into Imagick
       $im->readimageblob($tif);
       $im->setCompressionQuality(90);
       $im->setImageFormat('jpeg');
       $im->resizeImage(500, 500, imagick::FILTER_LANCZOS, 1);
       $jpg = base64_encode($im);
       //resize
       $labelImage = "data:image/gif;base64,' . $jpg . '";
       return $labelImage;
      // echo '<img src="data:image/gif;base64,' . $jpg . '" />';
}else{
    $labelImage ="/img/No-Labels-image.jpg";
}
}else{ 
    $labelImage ="/img/No-Labels-image.jpg";
}
return $labelImage;
}
?>