I have a php script that downloads a jpg to a temporary directory. The jpg is then converted to a png using ImageMagick. After completing the conversion, I use the php script to move (using rename()) the png to a live directory. I have another script that takes the newest image from the live directory and spits out the contents.
Originally I didn't have a temporary folder, and I ran into a major problem. The conversion process created the PNG file, but didn't actually finish writing all the contents of the png until half a second or so later. This meant the other script was occasionally reading an incomplete or corrupt image.
Will moving/renaming an image still leave the possibility of the php script reading an "incompletely-moved" image? From my understanding of computers, all that happens in a rename or move is that some paths between trees are moved around. The file itself is never even touched correct?
If we were talking about copying the png from a tmp directory to a live directory, we could potentially have that problem, correct? Although can a copied file even be accessed before it's finished copying?
Originally I didn't have a temporary folder, and I ran into a major problem. The conversion process created the PNG file, but didn't actually finish writing all the contents of the png until half a second or so later. This meant the other script was occasionally reading an incomplete or corrupt image.
Will moving/renaming an image still leave the possibility of the php script reading an "incompletely-moved" image? From my understanding of computers, all that happens in a rename or move is that some paths between trees are moved around. The file itself is never even touched correct?
If we were talking about copying the png from a tmp directory to a live directory, we could potentially have that problem, correct? Although can a copied file even be accessed before it's finished copying?