Edit report at http://bugs.php.net/bug.php?id=24450&edit=1

 ID:                 24450
 Comment by:         stano110 at azet dot sk
 Reported by:        choinet at rocketmail dot com
 Summary:            TTF and FreeType functions lock font file
 Status:             Wont fix
 Type:               Bug
 Package:            GD related
 Operating System:   Windows XP
 PHP Version:        4.3.3RC1
 Block user comment: N
 Private report:     N

 New Comment:

thanks for explanation. I have the same problem, cannot remove plugin
directory with the font locked. It's a pity, that this problem still
persists also on Win7+PHP5.3.3.


Previous Comments:
------------------------------------------------------------------------
[2003-07-14 18:24:43] [email protected]

Hello,



We cannot fix it. Freetype keeps the file handle open and windows
interprets that as a lock. Test your script on a unix system and it
should work like a charm.



thanks for your report,



pierre

------------------------------------------------------------------------
[2003-07-03 18:44:10] choinet at rocketmail dot com

I don't necessarily want to delete the file, but I want to be able to
hypothetically delete the parent directory above it :) I'm developing an
image management system that also allows for random image generation
with text, and perhaps I would need to remove a parent directory or the
file itself.

------------------------------------------------------------------------
[2003-07-01 18:37:04] [email protected]

Just curious..but why do you want to delete the file? :)



------------------------------------------------------------------------
[2003-07-01 17:45:37] choinet at rocketmail dot com

Description:
------------
My computer setup is Apache 2.0.46,PHP 4.3.2, and Windows XP SP1. Only
modifications to php.ini are: 'extension=php_gd2.dll' and 'log_errors'
are enabled. Originally, I was trying to use the imagettftext() function
to write text to a png file. I used the function in a similar context as
described by the manual, and the text write was successful. However, I
stumbled upon the discovery that the font file that the function uses
was locked by either the webserver or PHP process, as I was not able to
unlink or remove the font file.



I tried to isolate the problem by testing the code on Windows XP with
Apache 1.3.27, Apache 2.0.46, and IIS 5.1 and either PHP 4.2.3, 4.3.2,
4.3.3RC1, or 5.0, so I am thinking that it has something to do with the
operating system. Furthermore, this problem does not occur with a
webserver running Apache/PHP 4.3.2 on Linux. Also, this problem applies
to various true-type font files.



The problem only goes away after I stop or restart the webserver.



In summary, there are four functions that use a font file that lock it:
imagettftext(), imagettfbbox(), imagefttext(), and imageftbbox().









Reproduce code:
---------------
$im = imagecreatefrompng('test.png');

$blue = imagecolorallocate($im, 0, 102, 255);

$font = 'tahoma.ttf';

//

// These four functions lock the font file and do not release it

//

imagettftext($im, 10, 0, 10, 25, $blue, $font, 'text');

imagettfbbox (20, 0, $font, 'text');

imagefttext ($im, 12, 0, 10, 20, 5, $font, 'text', $foo);

imageftbbox (12, 0, $font, 'text', $foo);



header('Content-Type: image/png');

imagepng($im);

imagedestroy($im);



unlink($font);

Expected result:
----------------
I expect to see the png image generated and the font file unlinked.

Actual result:
--------------
The image displays fine but the font file cannot be deleted.



(Windows Error Dialog Box after manually attempting to delete
arial.ttf)



Cannot delete arial: It is being used by another person or program.
Close any programs that might be using the file and try again.



(Apache Error Log)



[client 127.0.0.1] PHP Warning:  unlink(arial.ttf): Permission denied in
C:\Apache2\htdocs\gd\dynamic.php on line 16


------------------------------------------------------------------------



-- 
Edit this bug report at http://bugs.php.net/bug.php?id=24450&edit=1

Reply via email to