Could not create temporary file

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
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Could not create temporary file

Post by anthony »

The temporary directory IM is using is either not writable, does not exist, or is disk full.
on UNIX-like systems you can set the temporary directory location (defaults to /tmp) using the environment variable "MAGICK_TEMPDIR". Or the command line option "-set registry:temporary-path {dir}". Under windows this is set using Registry entry "HKEY_Current_User\Environment\TMP"
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
MsXLabs

Re: Could not create temporary file

Post by MsXLabs »

Hello,

I've the same problem. It happened after i upgraded apache from 1.3 to 2.2 and php from 4 to 5.

All four servers have this problem now after the upgrade. I tried to reinstall the latest version of ImageMagick (downloaded it 2 days ago) by using this tutorial:
http://www.vbulletin.com/forum/showthread.php?t=155636

How can fix this problem?

"Could not create temporary file."

Regards
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: Could not create temporary file

Post by magick »

ImageMagick should report why ImageMagick fails to create a temporary file. For example,
  • -> setenv MAGICK_TMPDIR /
    -> convert logo.ps logo.miff
    convert: unable to create temporary file `logo.ps': Permission denied.
    convert: missing an image filename `logo.miff'.
which correctly reports that the temporary file cannot be written to the root directory since the user does not have permission to create a file in that directory. What does ImageMagick report when you get the "unable to create temporary file" message?
MsXLabs

Re: Could not create temporary file

Post by MsXLabs »

[root@server ~]# setenv MAGICK_TMPDIR /
-bash: setenv: command not found
[root@server ~]# convert logo.ps logo.miff
convert: missing an image filename `logo.miff'.
[root@server ~]#

Check these screenshots please:
http://dts.msxlabs.org/NeutralizeR/Snap132.png
http://dts.msxlabs.org/NeutralizeR/Snap29.png
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Could not create temporary file

Post by anthony »

You are probably use Bourne shell variant rather than Csh.
try...

Code: Select all

MAGICK_TMPDIR=/
export MAGICK_TMPDIR
However MAGICK_TMPDIR should be set to some directory that is writable!!!
Like some sub-directory of your home...

Code: Select all

mkdir $HOME/magick_tmp
MAGICK_TMPDIR=HOME/magick_tmp
export MAGICK_TMPDIR
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
MsXLabs

Re: Could not create temporary file

Post by MsXLabs »

[root@server ~]# MAGICK_TMPDIR=/
[root@server ~]# export MAGICK_TMPDIR
[root@server ~]# mkdir $HOME/magick_tmp
[root@server ~]# MAGICK_TMPDIR=HOME/magick_tmp
[root@server ~]# export MAGICK_TMPDIR
[root@server ~]# convert logo.ps logo.miff
convert: missing an image filename `logo.miff'.
[root@server ~]#


Still no changes at all.

http://www.msxlabs.org/forum/image.php?i=im

Could not create temporary file.
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: Could not create temporary file

Post by magick »

Perhaps you are missing Postscript support. Let's see if ImageMagick works from the command line. Do not set any environment variables and type:
  • convert logo: logo.miff
    convert logo.miff logo.pnm
If these commands fail, ImageMagick is not installed properly on your system. If they do work the temporary file problem is most likely related to you using ImageMagick from a scripting language whose environment/permissions differ than yours from the command line. Its possible, for example, that the script you are using sets the TMPDIR to a location where it does not have permission to write.
MsXLabs

Re: Could not create temporary file

Post by MsXLabs »

The commands worked.

But nothing changed at script side apart from Apache 2.2.6 update :(
MsXLabs

Re: Could not create temporary file

Post by MsXLabs »

Any solutions? I don't want to use GD. ImageMagick supports animated gif resizing...
MsXLabs

Re: Could not create temporary file

Post by MsXLabs »

Code: Select all

/**
	* See function definition in vB_Image_Abstract
	*/
	function print_image_from_string($string, $moveabout = true)
	{
		if ($this->registry->options['safeupload'])
		{
			$tmpname = $this->registry->options['tmppath'] . '/' . md5(uniqid(microtime()) . $this->registry->userinfo['userid']);
		}
		else
		{
			if (!($tmpname = @tempnam(ini_get('upload_tmp_dir'), 'vb')))
			{
				echo 'Could not create temporary file.';
				return false;
			}
		}
If i change the upload mode to safe mode, imagemagick's working.

What's the issue with the code above?
MsXLabs

Re: Could not create temporary file

Post by MsXLabs »

oh god, i changed the "upload_tmp_dir" value in php.ini to "upload_tmp_dir = /tmp" and the problem is fixed :)
Post Reply