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 7651999
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T11:39:10+00:00 2026-05-31T11:39:10+00:00

I am trying to generate images using ImageMagick, please check the code below: <?

  • 0

I am trying to generate images using ImageMagick, please check the code below:

<?
$label=$_POST["label"];
$image =$_POST["image"];
$cmd = " -background transparent label:\"$label\" -stroke red -strokewidth 0 ".
"  \( -clone 0 -tile \"" . $image . "[0]\" -stroke red -strokewidth 0 -gravity center  -annotate +0+0 \"$label\" \) ".
"  \( -clone 0 -tile \"" . $image . "[1]\" -stroke red -strokewidth 0 -gravity center -annotate +0+0 \"$label\" \) ".
"  \( -clone 0 -tile \"" . $image . "[2]\" -stroke red -strokewidth 0 -gravity center -annotate +0+0 \"$label\" \)  ".
"  \( -clone 0 -tile \"" . $image . "[3]\" -stroke red -strokewidth 0 -gravity center -annotate +0+0 \"$label\" \)  ".


 "  -delete 0 -set delay 20 -loop 0 -trim +repage -layers Optimize ";

$array=array();
echo "<pre>";
exec("convert $cmd masked.gif 2>&1", $array);
echo "<br>".print_r($array)."<br>";
echo "</pre>";
echo "<img src='masked.gif'>";
?>

Above code works fine by generating an image named as masked.gif, but I need to do two things now:

  1. Generated image should have a unique filename{every time it should generate different file name}
  2. Generated image should be saved in different folder not the root directory, let’s say the directory name as “coolpics” ,

Please help me to fix this. Your response is appreciated.

  • 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-31T11:39:12+00:00Added an answer on May 31, 2026 at 11:39 am
    1. For unique filename, check the uniqid function.
    2. For saving directory, just concatenate it with the filename, something like:
    // your command here
    
    $directory = "/data/images/coolpics/"
    $name = uniqid();
    exec(escapeshellcmd("convert $cmd $directory$name 2>&1"), $array);
    

    Note that you’re passing POST values directly to a system command, this can be a very serious security fail. Use escapeshellcmd to make sure your system is safe.

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

Sidebar

Related Questions

I'm using MagickCore to generate images from scratch. I'm trying to save my Image
I am trying the generate an image on the fly by merging images using
I'm trying to use imagemagick to generate some images of Kannada text. The problem
I'm using ASP.Net with MVC 3 and trying to auto generate images. In my
I am trying to generate an RSS feed on my site using the code
I get poor image quality when trying to generate image using PHP GD. Here
I'm trying to generate a multipage TIFF file from an existing picture using code
I am trying to write a code to generate a graph like this: http://www.mathgoodies.com/lessons/graphs/images/line_example1.jpg
currently i'm trying to use imagick to generate some images without saving them on
I'm trying to create a process to automatically generate thumbnails of the images uploaded

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.