Edit file, then insert back into file system


(Nic Hubbard) #1

I am having trouble figuring out if the following is possible with the Matrix file system.


Say I have a .jpg image, which, in php I write some text across the image, then re-save that image back into the same image location in the file system, but only as a .png file. How can I, then insert that new image, into the file system for that asset to replace the old, WITHOUT using the front-end upload?



Trying to change change the name, then delete gives me errors:


    $asset->setAttrValue('name', $new_name);


That gives me errors saying that I can't change the file extension, in order to, I would need to upload the file through the front end, which I don't want to do. :)

(Benjamin Pearson) #2

Have a look at image_edit_fns.inc, the function to help you out is: processFileUpload().


HTH


(Nic Hubbard) #3

[quote]Have a look at image_edit_fns.inc, the function to help you out is: processFileUpload().


HTH[/quote]



Ben, I guess I am not seeing a place in that function that you are referring to. It is a pretty short function, and no where do I see it referring to the current file in the file system. How, within this function, would I change the file to my new image w/ new extension?


(Benjamin Pearson) #4

Hey Nic,


Maybe you might be thinking of a different way of doing it, but I was meaning to use that function to upload the new image. This way, you don't have to worry about file versioning etc. and uploading a new file should allow for a filename change as well (not sure if it is automatic or not, this you may have to test)


(Nic Hubbard) #5

[quote]Hey Nic,


Maybe you might be thinking of a different way of doing it, but I was meaning to use that function to upload the new image. This way, you don't have to worry about file versioning etc. and uploading a new file should allow for a filename change as well (not sure if it is automatic or not, this you may have to test)[/quote]



Hmmm, I was meaning providing the new file path of the newly create image file, and inserting that one in place of the old, and updating the file info in the file system. All without using the front end upload button.


(Nic Hubbard) #6

Anyone? Is this method not ever used in Matrix?