How to create a new image?

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
derMatze

How to create a new image?

Post by derMatze »

I'm sorry, cause that may sound a little stupid, but: How can I just create a new blank image, using IM through php and the exec()-function?
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: How to create a new image?

Post by Bonzo »

Image 100 x 100 with a white background:

Code: Select all

exec("convert -size 100x100 -xc:white canvas.jpg");
derMatze

Re: How to create a new image?

Post by derMatze »

Nothin happended after doing that.
Even the $returnarray is empty and $returnvalue is 1 in
exec("convert -size 100x100 -xc:white canvas.jpg", $returnarray, $returnvalue);
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: How to create a new image?

Post by Bonzo »

Sorry my fault it should just be xc:white NOT -xc:white
derMatze

Re: How to create a new image?

Post by derMatze »

yes, thanks! :)
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: How to create a new image?

Post by anthony »

I suggest you get a command line version of IM, and play with that to get the results right. Then you can plug the command into PHP.

Oh and look though the IM Examples Web page.. Canvas Generation as a whole area just to itself.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: How to create a new image?

Post by Bonzo »

Updated code as requested to create an Image 100px x 100px with a white background:

Code: Select all

exec("convert -size 100x100 xc:white canvas.jpg");
Post Reply