Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6835215
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T23:12:21+00:00 2026-05-26T23:12:21+00:00

i am creating a new feature on my site that allow people to send

  • 0

i am creating a new feature on my site that allow people to send postcard to friends. in this section they can choose the image they want to send (they already uplaoded the image to their profile -> my pictures section)

i am using the php function to create the text that goes on the right but how can i add another image to this image with the text?

i use imagettftext to create the text, imagecreatefromjpeg to open the main image (see below) and imagedestroy when im done

thanks

i am using this postcard:
postcard-template.jpg

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T23:12:21+00:00Added an answer on May 26, 2026 at 11:12 pm

    First you will have to crop the image to fit in your postcard.
    Based on your image here’s what you have to do:

    <?php
    
    $sourceImage = './postcard-template.jpg';
    $uploadedImage = '/path/to/image/hong-kong2.jpg'; // let's get hong kong as example
    $mime = '';
    $font = '/path/to/font/arial.ttf'; 
    
    function CroppedThumbnail($source, $width, $height, &$mime) {
      $data = getimagesize($source);
      $sourceWidth = $data[0];
      $sourceHeight = $data[1];
      $mime = $data['mime'];
      $image = imagecreatefromjpeg($source);
      $sourceRatio = $sourceWidth/$sourceHeight;
      if (($width/$height) > $sourceRatio) {
        $newHeight = $width/$sourceRatio;
        $newWidth = $width;
      }
      else {
        $newWidth = $height*$sourceRatio;
        $newHeight = $height;
      }
      $croppedImage = imagecreatetruecolor(round($newWidth), round($newHeight));
      imagecopyresampled($croppedImage, $image, 0, 0, 0, 0, $newWidth, $newHeight, $sourceWidth, $sourceHeight);
      $thumb = imagecreatetruecolor($width, $height);
      imagecopyresampled($thumb, $croppedImage, 0, 0, (($newWidth/2)-($width/2)), (($newHeight/2)-($height/2)), $width, $height, $width, $height);
      imagedestroy($croppedImage);
      imagedestroy($image);
      return $thumb;
    }
    
    // Create the cropped image first
    $newThumb = CroppedThumbnail($uploadedImage,240,315, $mime);
    switch($mime) {
      case 'image/gif':
        $image = imagecreatefromgif($sourceImage);  
        break;
      case 'image/jpeg':
        $image = imagecreatefromjpeg($sourceImage);  
        break;
      case 'image/png':
        $image = imagecreatefrompng($sourceImage);  
        break;
      default:
        // error or stop script
        break;
    }
    $message = "this is some text\nsome other text\ntext text";
    
    imagettftext($image, 21, 0, 320, 255, imagecolorallocate($image, 0, 0, 0), $font, $message);
    imagecopy($image, $newThumb, 40, 40, 0, 0, 240, 315); 
    header('Content-Type: image/jpeg');
    imagejpeg($image); 
    imagedestroy($image);
    

    For example I use this image ( needs to be cropped ) :

    testimage

    then it will output:

    final

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm creating new Site Definitions using this method: http://weblogs.asp.net/paulballard/archive/2007/04/09/creating-a-custom-sharepoint-2007-portal-site-definition-using-the-portalprovisioningprovider-class.aspx and when they get created,
i am creating a related post article feature for my wordpress enabled site.being new
Can I avoid third party code from creating new threads, starting new VMs, or
I'm new to ruby, learning Sinatra. While creating a Sinatra site by requiring 'sinatra'
I am creating a new web app/service, one of the features of this service
I'm creating an MVC2 site which is a new, refreshed version of a site
I am creating a new WebSite whenever Feature A or B is installed: <Component
I'm creating a line which can be edited using this code: var line_points =
when i am creating new android project from visual studio 2010 it gives the
I have problem creating new instance of excel 2007 using VBA (from Access 2002).

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.