php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #50373 GD: image* should work with stream handles
Submitted: 2009-12-03 12:31 UTC Modified: 2010-04-28 16:44 UTC
From: rugkiks at gmail dot com Assigned: pajoye (profile)
Status: Duplicate Package: *General Issues
PHP Version: 5.3.1 OS: GNU/Linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: rugkiks at gmail dot com
New email:
PHP Version: OS:

 

 [2009-12-03 12:31 UTC] rugkiks at gmail dot com
Description:
------------
http://php.net/imagepng

Apparently there is not way to lock files while writing to them.

I'd like to see a similar behavior like the flags in 
http://php.net/file_put_contents

Maybe the file actually get's locked. I can't test it.

Reproduce code:
---------------
---
From manual page: function.imagepng#Description
---



Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-12-03 16:39 UTC] rasmus@php.net
I'm curious why you want this.  Locking is almost never the right 
solution for a web app.  Writing to a temp file and then atomically 
rename it into its final destination.  Adding locks to every library 
function PHP can call that can potentially write files is not feasible.
 [2009-12-03 20:25 UTC] pajoye@php.net
Same here, I don't see how we could do that for every simple file related functions. Please follow Rasmus' advice here, best possible solution.
 [2009-12-03 23:55 UTC] rugkiks at gmail dot com
It's the blocking feature i'm after. When the image is updating, 
other fopen's needs to get blocked. It makes my code much more 
simpler.

Also, you can do this with ImageMagick, since it allows you to 
supply the file handle yourself http://php.net/imagick_writeimagefile

The only reason why i'm requesting this feature to GD, is because of 
GD's speed.

rasmus: The renaming-method is nice. But in my case, i need the 
users to be blocked until the image is ready. Not just show the old 
one, or return a 404. I can program my way out of it, but it's 
messy.

I guess i'm saying that it would be nice with a 
http://php.net/imagick_writeimagefile for GD.

Thank you for the response.
 [2009-12-04 00:02 UTC] pajoye@php.net
Let see if we can get something non intrusive without adding yet another option to this function (already confusing :).
 [2009-12-04 00:18 UTC] rasmus@php.net
I still don't think it is a big deal.  Just create a filename.lck file 
and lock that while the image is being generated if you need that 
feature.  It is perhaps 2 extra lines of code.
 [2009-12-04 00:34 UTC] rugkiks at gmail dot com
Yes, it isn't a big deal, and not breaking my workflow. But i believe 
file-locking is there for a reason, and is a neat feature making my 
code cleaner :).

Tons of programs solve this by having .lock files, so i guess this is 
also an understandable code.
 [2010-04-28 16:41 UTC] pajoye@php.net
-Summary: GD: imagepng doesn't doesn't have lockflags +Summary: GD: image* should work with stream handles -Package: Feature/Change Request +Package: *General Issues
 [2010-04-28 16:41 UTC] pajoye@php.net
Update the summary to reflect the necessary change, which is not about adding a locking mechanism in gd.
 [2010-04-28 16:44 UTC] pajoye@php.net
-Status: Assigned +Status: Duplicate
 [2010-04-28 16:44 UTC] pajoye@php.net
Duplicate of FR #39263.
 
PHP Copyright © 2001-2017 The PHP Group
All rights reserved.
Last updated: Sun Nov 19 01:31:42 2017 UTC